我正在尝试使用 C 扩展文件构建共享库,但首先我必须使用以下命令生成输出文件:
gcc -Wall utilsmodule.c -o Utilc
执行命令后,我收到以下错误消息:
> utilsmodule.c:1:20: fatal error: Python.h: No such file or directory
compilation terminated.
我已经在互联网上尝试了所有建议的解决方案,但问题仍然存在。我没有问题.我设法在我的机器上找到了该文件。Python.h
网友回答:
在 Ubuntu 上,我运行的是 Python 3,我必须安装
sudo apt-get install python3-dev
如果要使用未链接到 python3 的 Python 版本,请安装关联的 python3.x-dev 包。例如:
sudo apt-get install python3.5-dev
网友回答:
看起来您尚未正确安装用于 python 开发的头文件和静态库。使用包管理器在系统范围内安装它们。
对于(Ubuntu,Debian…):apt
sudo apt-get install python-dev # for python2.x installs
sudo apt-get install python3-dev # for python3.x installs
对于(CentOS, RHEL…):yum
sudo yum install python-devel # for python2.x installs
sudo yum install python3-devel # for python3.x installs
对于(Fedora…):dnf
sudo dnf install python2-devel # for python2.x installs
sudo dnf install python3-devel # for python3.x installs
对于 (openSUSE…):zypper
sudo zypper in python-devel # for python2.x installs
sudo zypper in python3-devel # for python3.x installs
对于(阿尔卑斯山…):apk
# This is a departure from the normal Alpine naming
# scheme, which uses py2- and py3- prefixes
sudo apk add python2-dev # for python2.x installs
sudo apk add python3-dev # for python3.x installs
对于(Cygwin…):apt-cyg
apt-cyg install python-devel # for python2.x installs
apt-cyg install python3-devel # for python3.x installs
注意:python3-dev 不会自动涵盖 python3 的所有次要版本,如果您使用的是 python 3.8,则可能需要安装 python3.8-dev。
网友回答:
特别是对于Python 3.7和Ubuntu,我需要
sudo apt install libpython3.7-dev
.
我认为在某些时候名称已从此更改为此。pythonm.n-dev
对于 Python 3.6、3.8 到 3.10(以及计数…)类似:
sudo apt install libpython3.6-dev
sudo apt install libpython3.8-dev
sudo apt install libpython3.9-dev
sudo apt install libpython3.10-dev
模板简介:该模板名称为【致命错误: Python.h: 没有这样的文件或目录】,大小是暂无信息,文档格式为.编程语言,推荐使用Sublime/Dreamweaver/HBuilder打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【Python】栏目查找您需要的精美模板。