在virtualen中安装uwsgi时出错

2024-04-29 14:13:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在linux ubuntu,python 3.5.2上的virutal环境中安装uswgi 我知道

pip install uwsgi

我搞错了

Failed building wheel for uwsgi

在安装日志的最后

    *** 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/
  • Linux 4.4.0-66-通用x86_64
  • Python3.5.2

有什么解决办法吗?谢谢


Tags: installpipgnuubuntulinuxpluginscodeerror
3条回答

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

apt-get install python3.5-dev

上面的命令将安装Python 3头文件以从源代码构建uWSGI。

apt-get install build-essential python3-dev

从uWSGIdocumentation

uWSGI is a (big) C application, so you need a C compiler (like gcc or clang) and the Python development headers. On a Debian-based distro an apt-get install build-essential python-dev will be enough.

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

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

对于python 3.6中遇到相同问题的任何人,下面是解决该问题的步骤:

从这个ppa获得python 3.6开发工具:

sudo add-apt-repository ppa:deadsnakes/ppa

然后用以下内容更新包列表:

sudo apt-get update

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

apt-get install build-essential python3.6-dev

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

pip install uwsgi

相关问题 更多 >