Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing uwsgi with pip: "Python.h no such file". python-dev and python3-dev packages are installed

Tags:

python

pip

uwsgi

I'm getting the following error when trying to install uwsgi using pip on ubuntu 18.04:

$ sudo pip3 install uwsgi
...
    plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: No such file or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.

I have installed the python-dev and python3-dev packages. Running locate Python.h shows that it is indeed installed:

/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h

I've tried installing using both pip and pip3, and I get the same error. Every other answer to this question points to having python-dev or python3-dev or some variant installed, and I've tried all those. Any ideas what else might cause this?

like image 303
Ben Davis Avatar asked Nov 22 '19 19:11

Ben Davis


3 Answers

This is exactly the same problem I've faced today after I upgraded from 3.6 to 3.7.

Solve this problem by installing libpython3.7-dev:
sudo apt install libpython3.7-dev / libpython3.*-dev which version you use.

then install uwsgi again :
pip install uwsgi

the output should look like:

Building wheels for collected packages: uwsgi
  Running setup.py bdist_wheel for uwsgi ... done
  Stored in directory: /home/user/.cache/pip/wheels/2d/0c/b0/f3ba1bbce35c3766c9dac8c3d15d5431cac57e7a8c4111c268
Successfully built uwsgi
Installing collected packages: uwsgi, weasyprint
Successfully installed uwsgi-2.0.18 weasyprint-50

Hope this help.

like image 107
iColdPlayer Avatar answered Sep 24 '22 11:09

iColdPlayer


These two lines did the trick for me on Linux 8.2

yum install python3-devel
pip3 install uwsgi -vvv --no-cache-dir
like image 29
Mahi Avatar answered Sep 24 '22 11:09

Mahi


My python version is 3.6, I do this to solve my problem:

yum -y install python36-devel
like image 43
kameng Avatar answered Sep 24 '22 11:09

kameng