gpt4 book ai didi

python - fatal error : Python. h:没有这样的文件或目录

转载 作者:行者123 更新时间:2023-11-30 16:16:44 24 4
gpt4 key购买 nike

我正在尝试使用 C 扩展文件构建共享库,但首先我必须使用以下命令生成输出文件:

gcc -Wall utilsmodule.c -o Utilc

执行命令后,我收到此错误消息:

> utilsmodule.c:1:20: fatal error: Python.h: No such file or directory
compilation terminated.

我已经尝试了互联网上所有建议的解决方案,但问题仍然存在。我对 Python.h 没有任何问题。我设法在我的计算机上找到该文件。

最佳答案

看起来您还没有正确安装 python 开发的头文件和静态库。使用包管理器在系统范围内安装它们。

对于 apt(Ubuntu、Debian...):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev # for python3.x installs

对于 yum(CentOS、RHEL...):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel # for python3.x installs

对于dnf(Fedora...):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel # for python3.x installs

对于zypper(openSUSE...):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel # for python3.x installs

对于apk(Alpine...):

# 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

对于apt-cyg(Cygwin...):

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 - fatal error : Python. h:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56507936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com