用pip安装第三方包的时候,有时候会遇到fatal error: Python.h: No such file or directory compilation terminated
这样的报错。因为这些库使用了c扩展,需要编译,然后又找不到头文件和静态库导致的。编译这些c库需要的依赖库由python dev
提供,安装即可:
For apt (Ubuntu, 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…):
sudo yum install python-devel # for python2.x installs
sudo yum install python34-devel # for python3.4 installs
For dnf (Fedora…):
sudo dnf install python2-devel # for python2.x installs
sudo dnf install python3-devel # for python3.x installs
For zypper (openSUSE…):
sudo zypper in python-devel # for python2.x installs
sudo zypper in python3-devel # for python3.x installs