Tag Archives: Centos pip install uwsgi error

Centos pip install uwsgi error: “fatal error: Python.h: No such file or directory”

Halfway through the writing of the flask project, I was going to try to run it on the server. I thought that app.run() could not be used in the production environment, but Baidu wanted to use Ngix+uwsgi.

In line with the principle of pip all the way, first came a beautiful

1
pip3 install uwsgi

  Unfortunately reported an error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[gcc -pthread] core/zlib.o
    [gcc -pthread] core/regexp.o
    [gcc -pthread] core/routing.o
    [gcc -pthread] core/yaml.o
    [gcc -pthread] core/ssl.o
    [gcc -pthread] core/legion.o
    [gcc -pthread] core/xmlconf.o
    [gcc -pthread] core/dot_h.o
    [gcc -pthread] core/config_py.o
    *** uWSGI compiling embedded plugins ***
    [gcc -pthread] plugins/python/python_plugin.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
     #include <Python.h>
                        ^
    compilation terminated.
    ----------------------------------------
Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-dsr9i4nq/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-9835ofpr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-dsr9i4nq/uwsgi/

I can’t find python.h. It must be a dependency problem. A search on the Internet shows that the basic answer is to install python-dev and build-essential. I tried yum and found that the package was not found.

1
2
3
4
5
6
7
8
9
[root@VM_0_13_centos python3]# yum install python-dev
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
No package python-dev available.
Error: Nothing to do

  Think about yourself as python3, change your posture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@VM_0_13_centos python3]# yum install python3-dev
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
No package python3-dev available.
Error: Nothing to do
[root@VM_0_13_centos python3]# yum install python34-dev
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
No package python34-dev available.
Error: Nothing to do

This is fascinating

 

Solution:

Although the error reports are not consistent, I can’t find <python.h> anyway.

1
yum install python34-devel

After the installation is complete, then pip install uwsgi, a smooth journey.