栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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 
              ^~~~~~~~~~
    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 
              ^~~~~~~~~~
    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('rn', '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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942917.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号