Jon*_*han 10 c++ python compilation extending
我正在按照本教程学习如何使用C\C++代码扩展Python.
名为"使用GCC for Microsoft Windows构建扩展模块"的部分对我失败,出现以下错误:
fatal error: Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
名为"使用Microsoft Visual C++构建扩展模块"的部分也失败,但出现类似的错误:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决这个问题?
Kar*_*rim 51
对于Linux,Ubuntu用户在编译时解决缺少Python.h的问题,只需在终端中运行以下命令即可安装python的开发包:
在终端: sudo apt-get install python-dev
祝好运
sto*_*tal 17
弄清楚哪些失败将解决您的问题.
从您链接的文章:
gcc -c hellomodule.c -I/PythonXY/include
gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll
他们假设您在默认位置c:\ pythonXY中安装了python(其中X是主要版本号,Y是次要版本号).(在您的情况下是Python26)如果您将python放在其他位置将/ PythonXY替换为您安装的位置它.