Python C API使用WinPython Python解释器而不是标准Python解释器

Python C API use WinPython Python interpreter instead of standard python interpreter

本文关键字:Python 解释器 标准 WinPython API 使用      更新时间:2023-10-16

当将Python嵌入到我的C/c++应用程序中时,我如何正确使用在根目录"WinPython-64bit-3.4.4.1"中找到的WinPython的Python解释器,而不是在"WinPython-64bit-3.4.4.1/Python- 3.4.4.amd64"中找到的Python解释器?

当我尝试使用在"WinPython-64bit-3.4.4.1/python-3.4.4. exe"中找到的python解释器时。amd64"我无法成功运行模块。但是,当我使用根目录中找到的python解释器运行模块时,我能够正确运行我的模块。

我尝试将"WinPython解释器"重命名为"python",然后设置python home:

wchar_t PythonHome[1024];
std::wcsncpy(PythonHome, L"C:\Users\jchen114\Lasagne\WinPython\WinPython-64bit-3.4.4.1", 1024);
Py_SetPythonHome(PythonHome);
Py_Initialize();

我在使用标准python解释器运行模块时得到的错误是关于

"C:devMinGWbing++.exe" -shared -g ... sorry, an unimplemented: 64-bit mode not compiled in 
#include <Python.h>
^

这是否意味着我只需要一个64位的g++编译器?

请建议。

为了解决这个问题,WinPython附带了一个g++编译器。它在Scripts文件夹中。如果你把它放在你的路径上,就会有效果。