我正在关注 this tutorial关于如何使用 C\C++ 代码扩展 Python。
名为“使用 GCC 为 Microsoft Windows 构建扩展模块”的部分对我来说失败并出现以下错误:
fatal error: Python.h: No such file or directory
名为“使用 Microsoft Visual C++ 构建扩展模块”的部分也因类似错误而失败:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
我应该怎么做才能解决这个问题?
最佳答案
对于Linux、Ubuntu用户,解决编译时缺少Python.h的问题,只需在终端执行以下命令安装python的开发包即可:
在终端中:sudo apt-get install python-dev
祝你好运
关于c++ - 尝试编译 C 扩展模块时缺少 Python.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4097339/