我想在我的C++应用程序中嵌入Python 3.3.4,以便:
而且,事实上,我几乎成功地做到了.唯一仍然不起作用的是从ZIP存档导入标准库:它可以作为一个简单的目录工作,但每当我尝试压缩它时,初始化失败并出现以下错误:
Fatal Python error: Py_Initialize: unable to load the file system codec
Run Code Online (Sandbox Code Playgroud)
甚至可能使用最新的Python?我已经搜索了很多东西,很多消息来源声称在可执行文件附近放置正确的"python33.zip"应该可行.不过,我的实验证明不然.我错过了什么?
这是我的测试代码 - 由MS Visual Studio 2010制作的最小控制台应用程序,在Windows XP SP3上运行,并对我尝试的内容和结果有一些评论:
#include "stdafx.h"
#include "python.h"
int _tmain(int argc, _TCHAR* argv[])
{
// calling or not calling Py_SetProgramName doesn't seem to change anything
//Py_SetProgramName(argv[0]);
// python_lib is a directory with contents of python33/Lib
// python_lib.zip is an equivalent ZIP archive with contents of python33/Lib (without any top-level subdirs)
// _scripts.dat is a ZIP …Run Code Online (Sandbox Code Playgroud)