Error installing uwsgi in virtualenv
Solution 1
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.
Solution 2
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
Solution 3
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
Solution 4
Debian have package depending on all supported Python 3 development packages:
apt-get install python3-all-dev
Solution 5
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
Related videos on Youtube
Alvaro B
Updated on January 17, 2021Comments
-
Alvaro B over 3 years
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
-
Predicate over 2 yearsUpgrading python to 3.9.7 solved the problem for me.
-
Alvaro B almost 7 yearsThis works! Thanks!! now I have uWSGI installed in my virutal env. But i can not run it with python 3. I run with
sudo uwsgi --http :80 --wsgi-file main.py --callable app --master --processes 8 --threads 2
and I see this linePython version: 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
-
McGrady almost 7 yearsBecause
sudo
means to run some command as some other user (root by default), you can see this question. -
Alvaro B almost 7 yearsbut if I don't run like sudo, I can not run it using port 80
-
kore666 almost 6 years@AlvaroB, just install proper python version in virtualenv.
$ virtualenv -p python3.6 .venv
and then$ . .venv/bin/activate
and ' $ python --version ' must be3.6.x
-
Alvaro B over 5 yearsI have migrated to python3.6 and it's wokring fine. Thanks!
-
Bi Wu over 3 yearsThanks! You saved my time! I installed python3.7-dev as I use python3.7.9.
-
Isura Nimalasiri over 2 yearstry this , sudo uwsgi --socket 0.0.0.0:5000 --protocol=http --plugin python3 --module wsgi:app