简体   繁体   English

在 virtualenv 中安装 uwsgi 时出错

[英]Error installing uwsgi in virtualenv

I'm trying to install uswgi in a virutal env on linux ubuntu, python 3.5.2 I do我正在尝试在 linux ubuntu、python 3.5.2 上的虚拟环境中安装 uswgi

pip install uwsgi

I got this error我收到了这个错误

Failed building wheel for uwsgi

and at the end of the installing logs并在安装日志的末尾

    *** 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-generic x86_64 Linux 4.4.0-66-通用 x86_64
  • Python 3.5.2 Python 3.5.2

It is any solution for this?有什么解决方案吗? Thanks谢谢

You need to install Python3.5 development files, so run this command:你需要安装 Python3.5 的开发文件,所以运行这个命令:

apt-get install python3.5-dev

The above command will install Python 3 headers to build uWSGI from source.上面的命令将安装 Python 3 头文件以从源代码构建 uWSGI。

apt-get install build-essential python3-dev

From the uWSGI documentation :来自 uWSGI 文档

uWSGI is a (big) C application, so you need a C compiler (like gcc or clang) and the Python development headers. uWSGI 是一个(大)C 应用程序,因此您需要一个 C 编译器(如 gcc 或 clang)和 Python 开发头文件。 On a Debian-based distro an apt-get install build-essential python-dev will be enough.在基于 Debian 的发行版上,一个apt-get install build-essential python-dev就足够了。

For Python3, just change that to python3-dev .对于 Python3,只需将其更改为python3-dev

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

For anyone with python 3.6 facing the same problem here is the step to solve it :对于面临同样问题的 python 3.6 的任何人来说,这是解决它的步骤:

Get python 3.6 dev tools from this ppa:从此 ppa 获取 python 3.6 开发工具:

sudo add-apt-repository ppa:deadsnakes/ppa

Then update your package list with :然后使用以下命令更新您的包列表:

sudo apt-get update

and then install your dev tools with 3.6 version然后用 3.6 版本安装你的开发工具

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

Activate your virtual environment with and then install uwsgi:使用并安装 uwsgi 激活您的虚拟环境:

pip install uwsgi

Debian 有依赖于所有支持的 Python 3 开发包的包:

apt-get install python3-all-dev

I have faced the same issue.我遇到了同样的问题。 I solve it by following:我通过以下方式解决它:

sudo apt install libpython3.7-dev

If your python version is 3.6, then use 3.6 instead of 3.7.如果您的 python 版本是 3.6,则使用 3.6 而不是 3.7。 After that install uwsgi using pip:之后使用 pip 安装 uwsgi:

sudo pip install uwsgi

if you faced with the same problem while installing uwsgi under python3.6 just如果你在 python3.6 下安装 uwsgi 时遇到同样的问题

apt-get install python3.6-dev

In my case uwsgi installed via buildout在我的情况下,通过 buildout 安装 uwsgi

NOTE: may be you should add valid ppa注意:您可能应该添加有效的 ppa

或者,您可以使用conda安装uwsgi ,但请确保使用conda-forge通道:

conda install -c conda-forge uwsgi

You must install python3-devel package:您必须安装python3-devel包:

$ sudo dnf install python3-devel -y

And then install uwsgi module:然后安装uwsgi模块:

$ pip install uwsgi

For openSUSE (tumbleweed),对于 openSUSE(风滚草),

  1. I deactivated and deleted my venv我停用并删除了我的 venv
  2. installed python3-devel via yast2通过 yast2 安装 python3-devel
  3. then recreated and activated my venv然后重新创建并激活了我的 venv
  4. and pip install uwsgipip install uwsgi

if you want to install uwsgi command, through如果要安装 uwsgi 命令,通过

curl http://uwsgi.it/install | bash -s default /tmp/uwsgi

mv /tmp/uwsgi to /usr/local what ever mv /tmp/uwsgi 到 /usr/local 什么

I had a similar issue when installing uwsgi我在安装 uwsgi 时遇到了类似的问题

 ibpython3.7m.a’ generated with LTO version 6.0 instead of the expected 8.1. 

The default Python was 3.7 and I had to use pip3.8 to solve this problem.默认的 Python 是 3.7,我不得不使用 pip3.8 来解决这个问题。 However I have another problem.但是我还有另一个问题。 Running跑步

sudo uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app

generates the following error:生成以下错误:

uwsgi: invalid option -- 'w'
getopt_long() error

I have tried many things, including modular installation The main problem is that the default uwsgi folder is /usr/bin/uwsgi but when I install using pip3.8 it is not set to default.我尝试了很多东西,包括模块化安装主要问题是默认的 uwsgi 文件夹是 /usr/bin/uwsgi 但是当我使用 pip3.8 安装时它没有设置为默认值。 I couldn't resolve this problem and I switched to fastapi and uvicorn .我无法解决这个问题,我切换到fastapi 和 uvicorn I'm still interested to find the solution to my problem.我仍然有兴趣找到解决我的问题的方法。

I was stuck on this one, trying to install uwsgi on Unbuntu in Windows Linux Subsystem.我被困在这个上,试图在 Windows Linux 子系统的 Unbuntu 上安装 uwsgi。
Although it didn't give permission error, I solved it by running:虽然它没有给出权限错误,但我通过运行解决了它:

sudo pip install uwsgi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM