46

I'm trying to install lxml package on CentOS using sudo pip install lxml and its throwing this error right at the end:

error:

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
1
  • Can you share the relevant portion of /root/.pip/pip.log ? Commented Nov 13, 2013 at 14:12

9 Answers 9

64

" error: command 'gcc' failed with exit status 1 ". the installation failed because of missing python-devel and some dependencies.

the best way to correct gcc problem:

You need to reinstall gcc , gcc-c++ and dependencies.

For 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"

For python 3.4

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

Hope this will help.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm on centos and this worked: yum install python36-devel, followed by downloading your package (in my case python-ldap)
On fedora it's dnf install python3-devel
35

Is gcc installed?

sudo yum install gcc

3 Comments

Package gcc-4.4.7-3.el6.x86_64 already installed and latest version is already installed!!!!
Note that it reads 'command failed', not 'command not found '
is there any other way to install gcc other than yum as it is not allowed in sagemaker.
18

I bet you have to install libxml2-devel or libxml++-devel or even python-devel. But it is only a wild guess, not seeing the actual error from the log file. But it seems gcc is missing either a header file or a library file.

5 Comments

@damiefrancois - I tried installed those and I still get that error!
Do not try blindly. The error message states: Storing complete log in /root/.pip/pip.log so open that file, locate any errors and see exact error messages from gcc.
Installing python-devel fixed this for me. Thanks!
libxml++-devel installing this fixed for me
Solved installing mysql-devel (sudo yum install mysql-devel )
15
sudo yum install python36 python36-devel python36-libs python36-tools

if using python36, this is the best path for set up. Corrected this error for me on an aws ec2 instance

1 Comment

I got this error on aws ec2 amazon linux 2[ec2-user@IP ~]$ sudo yum install python36 python36-devel python36-libs python36-tools Loaded plugins: dkms-build-requires, extras_suggestions, langpacks, priorities, update-motd, versionlock No package python36 available. No package python36-devel available. No package python36-libs available. No package python36-tools available. Error: Nothing to do
6
yum install gcc-c++

It works for:

Fix “gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory” in Fedora

1 Comment

This is/was the solution for a vanilla Centos 8
4

How i solved

# 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

I hope it will help Someone to resolve "gcc" issue.

Comments

4
pip install -U pip
pip install -U cython

Comments

0

I faced this issue on CentOS while installing Fasttext. The issue is fixed with the following.

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

Reference: https://github.com/facebookresearch/fastText/issues/1105#issuecomment-667041482

If the above doesn't work, then try:

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

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

Comments

-1
yum install gcc-c++

centos GCP , this worked for me | Installing python3 lib implicit.

2 Comments

I'm not sure is the previous comment auto-generated, but I think I must reply here. I agree that my answer is already listed in aforementioned posts, but the problem there comes from different environment , different library.. At first, I tried to add an comment there, but I was unabled to do that because I have small reputation score.. Thanks for collaboration.
I wouldn't add another answer for a different platform. For example, I wouldn't expect there to be three answers for how to install pandas: pip install pandas for each of linux, windows, and mac. The other answer already has a comment centos, which has now been edited into that answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.