在virtualenv中安装uwsgi时出错

Alv*_*o B 25 python linux flask uwsgi

我正在尝试在Linux ubuntu,python 3.5.2上安装uswgi

pip install uwsgi
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误

Failed building wheel for uwsgi
Run Code Online (Sandbox Code Playgroud)

并在安装日志的末尾

    *** uWSGI compiling embedded plugins ***
[thread 0][x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
[thread 1][x86_64-linux-gnu-gcc -pthread] plugins/python/pyutils.o
In file included from plugins/python/python_plugin.c:1:0:
plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
compilation terminated.
In file included from plugins/python/pyutils.c:1:0:
plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
compilation terminated.

----------------------------------------

Command "/home/ubuntu/envflask/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wthov1ur/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-quiupta5-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/envflask/env/include/site/python3.5/uwsgi" failed with error code 1 in /tmp/pip-build-wthov1ur/uwsgi/
Run Code Online (Sandbox Code Playgroud)
  • Linux 4.4.0-66-通用x86_64
  • Python 3.5.2

这是什么解决方案?谢谢

McG*_*ady 34

您需要安装Python3.5开发文件,因此请运行以下命令:

apt-get install python3.5-dev
Run Code Online (Sandbox Code Playgroud)

上面的命令将安装Python 3标头以从源构建uWSGI.


JCo*_*ton 19

apt-get install build-essential python3-dev

从uWSGI 文档:

uWSGI是一个(大)C应用程序,因此您需要一个C编译器(如gcc或clang)和Python开发头文件.在基于Debian的发行版上 apt-get install build-essential python-dev就足够了.

对于Python3,只需将其更改为python3-dev.

$ python3 --version Python 3.5.2 $ pip3 freeze uWSGI==2.0.15


Esp*_*azi 7

对于使用python 3.6面临相同问题的任何人,这里是解决它的步骤:

从此PPA获取python 3.6开发工具:

sudo add-apt-repository ppa:deadsnakes/ppa
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令更新您的包裹清单:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

然后安装3.6版本的开发工具

apt-get install build-essential python3.6-dev
Run Code Online (Sandbox Code Playgroud)

使用激活您的虚拟环境,然后安装uwsgi:

pip install uwsgi
Run Code Online (Sandbox Code Playgroud)


mah*_*eju 6

我也遇到过同样的问题。我通过以下方式解决它:

sudo apt install libpython3.7-dev

如果你的python版本是3.6,那么使用3.6而不是3.7。之后使用 pip 安装 uwsgi:

sudo pip install uwsgi
Run Code Online (Sandbox Code Playgroud)


tjy*_*dsg 6

或者,您可以使用condainstall uwsgi,但请确保使用conda-forge频道:

conda install -c conda-forge uwsgi
Run Code Online (Sandbox Code Playgroud)


use*_*599 5

如果您在 python3.6 下安装 uwsgi 时遇到同样的问题

apt-get install python3.6-dev
Run Code Online (Sandbox Code Playgroud)

在我的例子中,uwsgi是通过buildout安装的

注意:也许您应该添加有效的 ppa


小智 5

Debian的软件包取决于所有受支持的Python 3开发软件包:

apt-get install python3-all-dev
Run Code Online (Sandbox Code Playgroud)