uwsgi 安装报错 plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

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$ 
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wohu007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值