Alvaro B
Alvaro B

Reputation: 646

Error installing uwsgi in virtualenv

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/

It is any solution for this? Thanks

Upvotes: 63

Views: 81211

Answers (12)

Elar Saks
Elar Saks

Reputation: 181

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

Upvotes: 2

soroush
soroush

Reputation: 177

You must install python3-devel package:

$ sudo dnf install python3-devel -y

And then install uwsgi module:

$ pip install uwsgi

Upvotes: 2

Matt Najarian
Matt Najarian

Reputation: 181

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.

Upvotes: 0

tjysdsg
tjysdsg

Reputation: 756

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

conda install -c conda-forge uwsgi

Upvotes: 7

mahbubcseju
mahbubcseju

Reputation: 2290

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

Upvotes: 6

penny chan
penny chan

Reputation: 847

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

Upvotes: 0

Espoir Murhabazi
Espoir Murhabazi

Reputation: 6376

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

Upvotes: 19

Aaron Williams
Aaron Williams

Reputation: 643

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

Upvotes: 0

neclude
neclude

Reputation: 81

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

apt-get install python3-all-dev

Upvotes: 8

kore666
kore666

Reputation: 1639

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

Upvotes: 5

JCotton
JCotton

Reputation: 11760

apt-get install build-essential python3-dev

From the uWSGI documentation:

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.

For Python3, just change that to python3-dev.

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

Upvotes: 38

McGrady
McGrady

Reputation: 11477

You need to install Python3.5 development files, so run this command:

apt-get install python3.5-dev

The above command will install Python 3 headers to build uWSGI from source.

Upvotes: 75

Related Questions