ubuntu18.04 安装uwsgi报错:error: Python.h: No such file or directory

输入命令:

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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值