使用pip安装uwsgi时出错:“ Python.h无此类文件”。安装了python-dev和python3-dev软件包

时间:2019-11-22 19:05:41

标签: python pip uwsgi

在ubuntu 18.04上尝试使用pip安装uwsgi时出现以下错误:

$ sudo pip3 install uwsgi
...
    plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: No such file or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.

我已经安装了python-devpython3-dev软件包。运行locate Python.h表明它确实已安装:

/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h

我尝试同时使用pippip3进行安装,但出现相同的错误。该问题的所有其他答案都指向已安装python-devpython3-dev或某些变体,而我已经尝试了所有这些方法。还有其他想法可能会导致这种情况吗?

3 个答案:

答案 0 :(得分:1)

这与我从3.6升级到3.7之后遇到的问题完全相同。

通过安装libpython3.7-dev解决此问题:
sudo apt install libpython3.7-dev / libpython3.*-dev使用哪个版本。

然后再次安装uwsgi
pip install uwsgi

输出应如下所示:

Building wheels for collected packages: uwsgi
  Running setup.py bdist_wheel for uwsgi ... done
  Stored in directory: /home/user/.cache/pip/wheels/2d/0c/b0/f3ba1bbce35c3766c9dac8c3d15d5431cac57e7a8c4111c268
Successfully built uwsgi
Installing collected packages: uwsgi, weasyprint
Successfully installed uwsgi-2.0.18 weasyprint-50

希望获得帮助。

答案 1 :(得分:0)

这两行代码在Linux 8.2上帮了我大忙

yum install python3-devel
pip3 install uwsgi -vvv --no-cache-dir

答案 2 :(得分:0)

我的python版本是3.6,我这样做是为了解决我的问题:

yum -y install python36-devel