pip安装时报【fatal error: Python.h: No such file or directory compilation terminated】错误

用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
    原文作者:pinkong
    原文地址: https://www.jianshu.com/p/e6945ac9c4c8
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞