1. Python3 安装 uwsgi 报错
直接使用命令 sudo pip3 install uwsgi
安装如下错误:
ubuntu@ubuntu:~/Downloads$ sudo pip3 install uwsgi
Collecting uwsgi
Downloading uwsgi-2.0.18.tar.gz (801 kB)
|████████████████████████████████| 801 kB 28 kB/s
Building wheels for collected packages: uwsgi
Building wheel for uwsgi (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xe2_vojh/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xe2_vojh/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d
In file included from plugins/python/pyloader.c:1:0:
plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
compilation terminated.
2. 解决方法
2.1 安装 aptitude
sudo apt-get install aptitude
2.2 使用 aptitude 安装依赖 python3-dev
sudo aptitude install python3-dev
注意:依次输入 n、y、y,详细内容见下:
ubuntu@ubuntu:~/Downloads$ sudo aptitude install python3-dev
The following NEW packages will be installed:
libpython3-dev{a} libpython3.5-dev{ab} python3-dev python3.5-dev{ab}
0 packages upgraded, 4 newly installed, 0 to remove and 38 not upgraded.
Need to get 37.7 MB of archives. After unpacking 53.9 MB will be used.
The following packages have unmet dependencies:
python3.5-dev : Depends: python3.5 (= 3.5.1-10) but 3.5.2-2ubuntu0~16.04.5 is installed.
Depends: libpython3.5 (= 3.5.1-10) but 3.5.2-2ubuntu0~16.04.5 is installed.
libpython3.5-dev : Depends: libpython3.5-stdlib (= 3.5.1-10) but 3.5.2-2ubuntu0~16.04.5 is installed.
Depends: libpython3.5 (= 3.5.1-10) but 3.5.2-2ubuntu0~16.04.5 is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libpython3-dev [Not Installed]
2) libpython3.5-dev [Not Installed]
3) python3-dev [Not Installed]
4) python3.5-dev [Not Installed]
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libpython3.5 [3.5.2-2ubuntu0~16.04.5 (now) -> 3.5.1-10 (xenial)]
2) libpython3.5-minimal [3.5.2-2ubuntu0~16.04.5 (now) -> 3.5.1-10 (xenial)]
3) libpython3.5-stdlib [3.5.2-2ubuntu0~16.04.5 (now) -> 3.5.1-10 (xenial)]
4) python3.5 [3.5.2-2ubuntu0~16.04.5 (now) -> 3.5.1-10 (xenial)]
5) python3.5-minimal [3.5.2-2ubuntu0~16.04.5 (now) -> 3.5.1-10 (xenial)]
Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
libpython3.5 libpython3.5-minimal libpython3.5-stdlib python3.5 python3.5-minimal
The following NEW packages will be installed:
libpython3-dev{a} libpython3.5-dev{a} python3-dev python3.5-dev{a}
0 packages upgraded, 4 newly installed, 5 downgraded, 0 to remove and 38 not upgraded.
Need to get 43.4 MB of archives. After unpacking 53.7 MB will be used.
Do you want to continue? [Y/n/?] y
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:47
ubuntu@ubuntu:~/Downloads$
2.3 再执行 sudo pip3 install uwsgi
sudo pip3 install uwsgi
验证是否安装成功
ubuntu@ubuntu:~/Downloads$ uwsgi --version
2.0.18
ubuntu@ubuntu:~/Downloads$