错误:命令'gcc'在CentOS上失败,退出状态为1

sc4hvdpw  于 2022-11-07  发布在  其他
关注(0)|答案(9)|浏览(308)

我尝试使用sudo pip install lxml在CentOS上安装lxml包,它在最后抛出了以下错误:

错误:

error: command 'gcc' failed with exit status 1

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

Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PjviBq-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/lxml
Storing complete log in /root/.pip/pip.log

[hg@user-centos-1 ~]$ error: command 'gcc' failed with exit status 1
bash: error:: command not found
41ik7eoe

41ik7eoe1#

“错误:命令'gcc'失败,退出状态为1“。安装失败,因为缺少python-devel和某些依赖项。
纠正GCC问题的最佳方法:
您需要重新安装gcc、gcc-c++和依赖项。
对于Python 2.7

$ sudo yum -y install gcc gcc-c++ kernel-devel
$ sudo yum -y install python-devel libxslt-devel libffi-devel openssl-devel
$ pip install "your python packet"

对于Python 3.4

$ sudo apt-get install python3-dev
$ pip install "your python packet"

希望这会有所帮助。

lskq00tm

lskq00tm2#

是否安装了gcc?

sudo yum install gcc
7jmck4yq

7jmck4yq3#

我敢打赌你必须安装libxml2-devellibxml++-devel甚至python-devel。但这只是一个大胆的猜测,没有看到日志文件中的实际错误。但似乎gcc缺少一个头文件或一个库文件。

goucqfw6

goucqfw64#

sudo yum install python36 python36-devel python36-libs python36-tools

如果使用python36,这是设置的最佳路径。在aws ec2示例上为我更正了此错误

mfuanj7w

mfuanj7w6#

我是怎么解决的


# yum update

# yum install -y https://centos7.iuscommunity.org/ius-release.rpm

# yum install -y python36u python36u-libs python36u-devel python36u-pip

# pip3.6 install pipenv

我希望这将有助于有人解决“gcc”的问题。

lb3vh1jj

lb3vh1jj7#

pip install -U pip
pip install -U cython
gajydyqb

gajydyqb8#

我在安装Fasttext时在CentOS上遇到了这个问题。这个问题通过以下方法得到了修复。

yum install centos-release-scl
yum install scl-utils-build
yum install devtoolset-9
scl enable devtoolset-9 bash

参考:https://github.com/facebookresearch/fastText/issues/1105#issuecomment-667041482
如果以上方法无效,请尝试:

yum install gcc libffi-devel python-devel openssl-devel -y

参考:https://support.huaweicloud.com/intl/en-us/trouble-ecs/ecs_trouble_0356.html

mqxuamgl

mqxuamgl9#

yum install gcc-c++

centos GCP,这对我很有效|隐式安装python3库。

相关问题