Error installing uwsgi in virtualenv

Viewed 60429

I'm trying to install uswgi in a virutal env on linux ubuntu, python 3.5.2 I do

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
  • Python 3.5.2

It is any solution for this? Thanks

12 Answers

For anyone with python 3.6 facing the same problem here is the step to solve it :

Get python 3.6 dev tools from this ppa:

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

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

Activate your virtual environment with and then install uwsgi:

pip install uwsgi

Debian have package depending on all supported Python 3 development packages:

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. After that install uwsgi using pip:

sudo pip install uwsgi

if you faced with the same problem while installing uwsgi under python3.6 just

apt-get install python3.6-dev

In my case uwsgi installed via buildout

NOTE: may be you should add valid ppa

Alternatively, you can use conda to install uwsgi, but make sure to use conda-forge channel:

conda install -c conda-forge uwsgi

You must install python3-devel package:

$ sudo dnf install python3-devel -y

And then install uwsgi module:

$ pip install uwsgi

For openSUSE (tumbleweed),

  1. I deactivated and deleted my venv
  2. installed python3-devel via yast2
  3. then recreated and activated my venv
  4. and pip install uwsgi

if you want to install uwsgi command, through

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

mv /tmp/uwsgi to /usr/local what ever

I had a similar issue when installing 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. 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. I couldn't resolve this problem and I switched to fastapi and 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.
Although it didn't give permission error, I solved it by running:

sudo pip install uwsgi
Related