输入命令:
pip3 install uwsgi
报错提示如下:
[thread 1][x86_64-linux-gnu-gcc -pthread] core/dot_h.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/config_py.o
*** uWSGI compiling embedded plugins ***
[thread 1][x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
[thread 0][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:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyutils.c:1:0:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-auludrz2/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-hk_qf037-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-auludrz2/uwsgi/
前面的报错就省略了,主要看最后几行。提示我找不到Python.h文件,大概问题就出现在python3的环境下。我目前的python3是3.8.0,pip3也是同样的版本,问题就是出现在其他地方。(如果是这里版本不匹配的朋友可以试试把python3或者pip3的python3版本换成一样的)
然后我面向百度搜索发现,其他人的解决方法是:
sudo apt-get install -y python3-dev
然后我照做后提示我:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-dev is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
哦豁,提示我已经存在,但是版本是3.6.9。这很有可能就是问题所在,于是我是这样做的:删除然后下载对应版本。
sudo aptitude remove python3-dev # 用aptitude可以删除相关的依赖包
sudo aptitude install python3.8-dev
最后,成功了!
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.20