记一次pip/pip3安装uwsgi报错

在CentOS7.9系统中尝试使用Linux+Nginx+uWSGI部署Flask应用时,遇到pip安装uWSGI失败的错误。经过排查和尝试更新pip、安装Python3-devel等方法无效后,发现是缺少gcc-c++导致的编译问题。安装gcc-c++后,成功安装了uWSGI。
摘要由CSDN通过智能技术生成

背景

本来是想着在centos 7.9的主机上面部署一个flask应用,采用的方式是linux+nginx+uwsgi来进行发布,其他的都没有问题,但是在使用pip安装uwsgi时报错了,安装不成功,查了很多方法:试过把pip更新、安装python3-devel等等,但都是不行,最后还是得靠自己,研究了下pip安装方式,发现安装uwsgi是编译安装的,最后一查询发现gcc-c++没有装,安装之后再去安装uwsgi发现就成功。

问题描述

下面是我安装的时候的报错:
[root@* ~]# sudo pip3 install uwsgi
WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead.
Collecting uwsgi
Using cached https://files.pythonhosted.org/packages/b3/8e/b4fb9f793745afd6afcc0d2443d5626132e5d3540de98f28a8b8f5c753f9/uwsgi-2.0.21.tar.gz
Installing collected packages: uwsgi
Running setup.py install for uwsgi … error
Complete output from command /usr/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-8796okps/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-2_lro4bs-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘descriptions’
warnings.warn(msg)
running install
using profile: buildconf/default.ini
detected include path: [‘/usr/include’, ‘/usr/local/include’]
Traceback (most recent call last):
File “/tmp/pip-build-8796okps/uwsgi/uwsgiconfig.py”, line 750, in init
gcc_version_components = gcc_version.split(‘.’)
AttributeError: ‘NoneType’ object has no attribute ‘split’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-8796okps/uwsgi/setup.py", line 143, in <module>
    'Programming Language :: Python :: 3.11',
  File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/tmp/pip-build-8796okps/uwsgi/setup.py", line 77, in run
    conf = uc.uConf(get_profile())
  File "/tmp/pip-build-8796okps/uwsgi/uwsgiconfig.py", line 758, in __init__
    raise Exception("you need a C compiler to build uWSGI")
Exception: you need a C compiler to build uWSGI

----------------------------------------

Command “/usr/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-8796okps/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-2_lro4bs-record/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-build-8796okps/uwsgi/

解决方案

[root@* ~]# yum -y install python3-devel
[root@* ~]# yum -y installl gcc-c++
安装好之后再pip安装uwsgi就没问题了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

避凉闲庭

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

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

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

打赏作者

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

抵扣说明:

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

余额充值