使用 pip 安装 uwsgi 时出错:“Python.h 没有这样的文件”。安装了 python-dev 和 python3-dev 包

Ben*_*vis 8 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.
Run Code Online (Sandbox Code Playgroud)

我已经安装了python-devpython3-dev包。运行locate Python.h显示确实安装了:

/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h
Run Code Online (Sandbox Code Playgroud)

我试过同时使用pipand 进行安装pip3,但出现相同的错误。每隔回答这个问题分有python-devpython3-dev或其变型安装的,我已经尝试了所有这些。任何想法还有什么可能导致这种情况?

iCo*_*yer 12

这也正是我今天所面临后我从升级同样的问题3.63.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
Run Code Online (Sandbox Code Playgroud)

希望这有帮助。

  • `sudo apt install libpython3-all-dev` 包取决于所有支持的 Python 3 开发包。 (4认同)
  • @iColdPlayer 我对你感激不尽。您的解决方案挽救了生命。它刚刚起作用了。 (2认同)
  • 在 Ubuntu 20.04 LTS 上安装 `build-essential` 后解决了我的问题。我使用了“libpython3.8-dev”。谢谢。 (2认同)

小智 7

这两行在 Linux 8.2 上对我有用

yum install python3-devel
pip3 install uwsgi -vvv --no-cache-dir
Run Code Online (Sandbox Code Playgroud)