Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

python - 致命错误:Python.h:没有这样的文件或目录(fatal error: Python.h: No such file or directory)

I am trying to build a shared library using a C extension file but first I have to generate the output file using the command below:

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

gcc -Wall utilsmodule.c -o Utilc

After executing the command, I get this error message:

(执行命令后,我得到以下错误消息:)

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

(utilsmodule.c:1:20:致命错误:Python.h:没有此类文件或目录编译终止。)

in fact I have tried all the suggested solutions over the internet but the problem still exists ... also I have no problem with Python.h .

(实际上,我已经尝试了所有建议的解决方案,但是仍然存在该问题……对于Python.h我也没有问题。)

I managed to locate the file on my machine ... anybody has faced the same problem before??

(我设法在我的机器上找到该文件……以前有人遇到过同样的问题吗??)

  ask by Mohanad Y. translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Looks like you haven't properly installed the header files and static libraries for python dev.

(看来您尚未正确安装python dev的标头文件和静态库。)

Use your package manager to install them system-wide.

(使用软件包管理器在系统范围内安装它们。)

For apt ( Ubuntu, Debian... ):

(对于aptUbuntu,Debian ... ):)

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

For yum ( CentOS, RHEL... ):

(对于yumCentOS,RHEL ... ):)

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

For dnf ( Fedora... ):

(对于dnfFedora ... ):)

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

For zypper ( openSUSE... ):

(对于zypperopenSUSE ... ):)

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

For apk ( Alpine... ):

(对于apkAlpine ... ):)

# 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

For apt-cyg ( Cygwin... ):

(对于apt-cygCygwin ... ):)

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...