我正在关注关于如何使用 CC++ 代码扩展 Python 的本教程.
I'm following this tutorial on how to extend Python with CC++ code.
名为Building the extension module with GCC for Microsoft Windows"的部分对我来说失败并出现以下错误:
The section named "Building the extension module with GCC for Microsoft Windows" fails for me with the following error:
fatal error: Python.h: No such file or directory
名为使用 Microsoft Visual C++ 构建扩展模块"的部分也失败并出现类似错误:
The section named "Building the extension module using Microsoft Visual C++" also fails with a similar error:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
我该怎么做才能解决这个问题?
What should I do to solve this?
找出哪些失败将解决您的问题.
Figuring out which of those is failing will solve your problem.
来自您链接的文章:
gcc -c hellomodule.c -I/PythonXY/include
gcc -c hellomodule.c -I/PythonXY/include
gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll
gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll
他们假设您在默认位置 c:pythonXY 安装了 python(其中 X 是主要版本号,Y 是次要版本号).(在您的情况下为 Python26)如果您将 python 放在其他地方,请将/PythonXY 替换为 where你安装过它.
They assumed you installed python in the default location c:pythonXY(Where X is the major version number and Y is the minor version number).(in your case Python26) If you put python somewhere else replace /PythonXY with where ever you installed it.
这篇关于尝试编译 C 扩展模块时缺少 Python.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!