sudo apt-get install python-dev # for python2.x installssudo apt-get install python3-dev # for python3.x installs
对于yum(CentOS RHEL…):
sudo yum install python-devel # for python2.x installssudo yum install python3-devel # for python3.x installs
对于dnf(Fedora…):
sudo dnf install python2-devel # for python2.x installssudo dnf install python3-devel # for python3.x installs
对于zypper(OpenSUSE…):
sudo zypper in python-devel # for python2.x installssudo zypper in python3-devel # for python3.x installs
对于apk(高山…):
# This is a departure from the normal Alpine naming# scheme, which uses py2- and py3- prefixessudo apk add python2-dev # for python2.x installssudo apk add python3-dev # for python3.x installs
对于apt-cyg(Cygwin…):
apt-cyg install python-devel # for python2.x installsapt-cyg install python3-devel # for python3.x installs
当我尝试使用Python3.6在CentOS 7上安装ctds时发生了此错误。我做了这里提到的所有技巧,包括yum install python34-devel。问题是Python.h在/usr/include/python3.4m but not in /usr/include/python3.6m中找到。我尝试使用--global-option指向包含dir(pip3.6 install --global-option=build_ext --global-option="--include-dirs=/usr/include/python3.4m" ctds)。这导致在链接ctds时找不到lpython3.6m。
gcc -c mypythonprogram.c $(python3-config --includes)gcc -o program mypythonprogram.o $(python3-config --ldflags)
The python-config program can be named after the Python versions - on Debian, Ubuntu for example these can be named python3-config or python3.6-config.
# Install python3-devel like everyone saysyum -y install python36-devel.x86_64
# Find the install directory of `Python.h`rpm -ql python36-devel.x86_64 | grep -i "Python.h"
# Forcefully add it to your include pathC_INCLUDE_PATH='/usr/include/python3.6m'export C_INCLUDE_PATH
Docker解决方案:
# Install python3-devel like everyone saysRUN yum -y install python36-devel.x86_64
# Find the install directory of `Python.h`, for me it was /usr/include/python3.6mRUN rpm -ql python36-devel.x86_64 | grep -i "Python.h" && fake_command_so_docker_fails_and_shows_us_the_output
# Since the previous command contains a purposeful error, remove it before the next run
# Forcefully add it to your include pathARG C_INCLUDE_PATH='/usr/include/python3.6m'