505

When I try to install odoo-server, I got the following error:

error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Could anyone help me to solve this issue?

3
  • 9
    Sometimes it's the line above this error you should look at. It should tell you what package is missing. Feb 22, 2018 at 17:01
  • The most frustrating thing is that it hides the actual error message.
    – Velkan
    Apr 12, 2021 at 13:54
  • If you have received this error message while trying to install Odoo, Kenly's answer is the most applicable. Otherwise, consider for a Q&A more specific to the package that you are trying to install, and the object that GCC is unable to locate. Jan 12, 2023 at 12:04

38 Answers 38

622

I encountered the same problem in college having installed Linux Mint for the main project of my final year, the third solution below worked for me.

When encountering this error please note before the error it may say you are missing a package or header file — you should find those and install them and verify if it works (e.g. ssl → libssl).

For Python 2.x use:

sudo apt-get install python-dev

For Python 2.7 use:

sudo apt-get install libffi-dev

For Python 3.x use:

sudo apt-get install python3-dev

or for a specific version of Python 3, replace x with the minor version in

sudo apt-get install python3.x-dev
23
  • 8
    Helped for python 3
    – viddik13
    Oct 30, 2016 at 16:48
  • 4
    sudo apt-get install python3.6-dev solved for me . because i updated to 3.6
    – Karan
    Mar 23, 2018 at 8:34
  • 86
    I use additionally apt-get install build-essential to solve my problem. Jan 12, 2019 at 1:05
  • 24
    I had already installed python3.x-dev but still had problems, but Samuel's suggestion of sudo apt-get install build-essential worked perfectly Jan 11, 2021 at 12:19
  • 5
    sudo apt-get install python3.9-dev works like a charm :)
    – Saeed
    May 6, 2021 at 7:41
292

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications.

enter:

$ sudo apt-get install python-dev

or

# apt-get install python-dev

see http://www.cyberciti.biz/faq/debian-ubuntu-linux-python-h-file-not-found-error-solution/

10
  • 51
    This did not solve the problem for me: Reading state information... Done python-dev is already the newest version.
    – 8bitjunkie
    Aug 17, 2015 at 22:04
  • 87
    @SummerSun If you're using python3, you should use: $sudo apt-get install python3-dev or $ sudo apt-get install python3.4-dev Apr 1, 2016 at 14:52
  • @antoinet but i am using python 2.7.4... I have solved this long ago but i don't remember any specific solution
    – Summer Sun
    Apr 4, 2016 at 6:22
  • 2
    For python3.x use the command $sudo apt-get install python3.x-dev Jan 9, 2019 at 5:03
  • 7
    if you are using ubuntu, you also need to install build-essential. check this answer: stackoverflow.com/a/54534118/3453776
    – nnov
    Nov 13, 2019 at 12:48
204

Try installing these packages.

sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-pil python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev libssl-dev

sudo easy_install greenlet

sudo easy_install gevent
21
  • 5
    i didn't found any reasonable answer about why this error happen! why we need to install all these packages...if possible then kindly explain "'x86_64-linux-gnu-gcc' failed" to me
    – Shashank
    Feb 9, 2015 at 11:59
  • 164
    Yeah, one of these packages might fix it but it would be nice to know which one particularly Feb 17, 2015 at 14:37
  • 42
    build-essential and python-dev were enough in my case.
    – Alfabravo
    Nov 23, 2015 at 0:42
  • 88
    Downvoted for not answering the question. Why do I have to install qt4-docs to fix this problem?
    – reggie
    Nov 26, 2015 at 10:13
  • 14
    build-essential and python-dev is enough for my
    – vinayrks
    Feb 20, 2016 at 14:02
145

You need to install these packages:

sudo apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev libjpeg-dev zlib1g-dev
9
  • 4
    This one worked for me. I had all python and build packages from previous answers, I was missing these lib* packages. THANKS!
    – shadyyx
    Dec 28, 2016 at 14:07
  • 1
    Worked on void linux.
    – xaos_xv
    Feb 1, 2019 at 19:37
  • 1
    This will most likely work on clean systems, but in my case all I was missing was the 3 packages: libldap2-dev, libpq-dev and libsasl2-dev
    – Anas Tiour
    Mar 19, 2019 at 2:03
  • Worked for Ubuntu 19.10 with Python 3.7 Apr 27, 2020 at 17:14
  • 1
    This worked for me. Ubuntu 18.04, Python 3.9.6. Jul 18, 2021 at 23:35
90

For Python 3.5 use:

sudo apt-get install python3.5-dev

For Python 3.6 use:

sudo apt-get install python3.6-dev

For Python 3.7 use:

sudo apt-get install python3.7-dev

For Python 3.8 use:

sudo apt-get install python3.8-dev

... and so on ...

6
  • 6
    As a side note, I just used sudo apt-get install python3.6-dev and it also worked.
    – Or Duan
    Mar 23, 2017 at 7:44
  • 1
    Boy that was tough -- I installed everything mentioned above on my system until this one finally fixed it for me. I'm using a virtualenv with python3.6. Thank you for that.
    – SteveJ
    Nov 10, 2017 at 21:48
  • 1
    I'm using the Python3.8 sudo apt-get install python3.8-dev May 28, 2020 at 1:37
  • 2
    With every new version of python I land here again :-) Oct 9, 2020 at 12:14
  • 1
    So clean that is it not even reasonable! Thanks! Oct 21, 2021 at 12:23
74
$ sudo apt-get install gcc
$ sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi

OR TRY THIS:

$ sudo apt-get install libxml2-dev libxslt1-dev
0
39

For me none of above worked. However, I solved problem with installing libssl-dev.

sudo apt-get install libssl-dev

This might work if you have same error message as in my case:

fatal error: openssl/opensslv.h: No such file or directory ... .... command 'x86_64-linux-gnu-gcc' failed with exit status 1

4
  • 2
    Me too. The accepted answer seems a little excessive.
    – Esteban
    Sep 30, 2016 at 18:14
  • This worked for me as well without having to download a bunch from the accepted answer
    – DanMossa
    Nov 29, 2016 at 4:37
  • 1
    This is usually this library that is missing when I install cryptography package in python.
    – Pobe
    Aug 3, 2017 at 14:36
  • This was the issue for me too. I could tell it from the stdout line "src/pycurl.h:164:28: fatal error: openssl/ssl.h: No such file or directory" printed just before the line questioned in this post "error: command 'x86_64-linux-gnu-gcc' failed with exit status 1"
    – claudod
    Jul 9, 2018 at 15:14
39

In my case, it was missing package libffi-dev.

What worked:

sudo apt-get install libffi-dev
0
29

In my case following command did the magic

sudo apt-get install gcc python3-dev

if the above command didn't work try following two commands

sudo apt-get install gcc python-dev
  1. this is the case when you want it to install for the python version set as default python in your machine.

Or

sudo apt-get install gcc python3.x-dev
  1. where python3.x represent the version number of python installed on your machine.
2
  • 4
    python3.7-dev package helped me. All the others not really. Only after I installed this one it worked. May 19, 2021 at 15:58
  • 1
    i love u it was gcc for me and python3-dev :)
    – nmu
    Sep 22, 2022 at 8:46
17

on ubuntu 14.04:

sudo apt-file search ffi.h 

returned:

chipmunk-dev: /usr/include/chipmunk/chipmunk_ffi.h
ghc-doc: /usr/share/doc/ghc-doc/html/users_guide/ffi.html
jython-doc: /usr/share/doc/jython-doc/html/javadoc/org/python/modules/jffi/jffi.html
libffi-dev: /usr/include/x86_64-linux-gnu/ffi.h
libffi-dev: /usr/share/doc/libffi6/html/Using-libffi.html
libgirepository1.0-dev: /usr/include/gobject-introspection-1.0/girffi.h
libgirepository1.0-doc: /usr/share/gtk-doc/html/gi/gi-girffi.html
mlton-basis: /usr/lib/mlton/include/basis-ffi.h
pypy-doc: /usr/share/doc/pypy-doc/html/config/objspace.usemodules._ffi.html
pypy-doc: /usr/share/doc/pypy-doc/html/config/objspace.usemodules._rawffi.html
pypy-doc: /usr/share/doc/pypy-doc/html/rffi.html

I chose to install libffi-dev

sudo apt-get install libffi-dev

worked perfectly

2
  • 3
    Not only this solution helped me fix my ffi.h missing dependency but also helped fixing other missing dependencies. Thanks!
    – Dário
    Sep 27, 2016 at 10:13
  • This really helped. I was missing file called pcrecpp.h. And the package I had to install was libpcre3-dev. Feb 21, 2020 at 19:06
17

In my case pip was unable to install libraries, I tried solutions given above, but none worked but the below worked for me:

sudo apt upgrade gcc
1
  • 1
    Usually this Happens when we dont use environment
    – yunus
    Jan 23, 2019 at 10:04
11

Despite being an old question, I'll add my opinion.

I think the right answer depends on the error message of the gcc compiler, something like "Missing xxxx.h"

This might help in some cases:

sudo apt-get install build-essential python-dev
0
9

This was enough for me:

sudo apt-get install build-essential
6

In Linux Mint with python3

$ sudo apt install build-essential python3-dev

should be enough

0
5

below answer worked for me, you can try:

sudo apt-get install python3-lxml
1
  • And for python2:sudo apt-get install python-lxml
    – Ajeet Shah
    Jul 19, 2016 at 5:51
5

Using Ubuntu 14.04 LTS with a virtualenv running python 3.5, I had to do:

sudo apt-get install python3.5-dev

The other commands:

sudo apt-get install python-dev
sudo apt-get install python3-dev

Did not help. I think this is because the virtualenv needs to rely on the system-wide python-dev package and it must match the virtualenv's python version. However, using the above commands installs python-dev for python 2.x and the python 3.x that comes with Ubuntu 14.04 which is 3.4, not 3.5.

5

Error : error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Executing sudo apt-get install python-dev solved the error.

1
  • 2
    Or executing sudo apt-get install python3-dev.
    – ecolell
    Jul 18, 2018 at 18:49
4

After upgrade my computer with pip today, and check the other answers here, I can tell you that it could be ANYTHING. You should check error by error, looking for what's the specific library that you need. In my case, these were the libraries that I had to install:

$ sudo apt-get install libssl-dev
$ sudo apt-get install libffi-dev
$ sudo apt-get install libjpeg-dev
$ sudo apt-get install libvirt-dev
$ sudo apt-get install libsqlite3-dev
$ sudo apt-get install libcurl4-openssl-dev
$ sudo apt-get install libxml2-dev libxslt1-dev python-dev

HTH

4

first you need to find out what the actual problem was. what you're seeing is that the C compiler failed but you don't yet know why. scroll up to where you get the original error. in my case, trying to install some packages using pip3, I found:

    Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-4u59c_8b/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-itjeh3va-record/install-record.txt --single-version-externally-managed --compile --user:
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

 #include <ffi.h>

                 ^

compilation terminated.

so in my case I needed to install libffi-dev.

1
  • 1
    For sure, this compiler error presented on the question, is very relative. My case, for example, was just like yours: I was installing bcrypt via pip3, and the output was quite huge and observing the first messages from pip3 install bcrypt, I realized that libffi-dev was the package which was causing all the trouble for the next steps of the installation process. Well observed, friend :). I hope you don't my mind, if I give some cents to your answer, which for me, deserves a better consideration. Regards.
    – ivanleoncz
    Mar 12, 2018 at 20:33
4

This works for me, 12.04, python2.7.6

sudo apt-get install libxml2 libxml2-dev libxslt1-dev
sudo apt-get install lxml
2
  • 1
    E: Unable to locate package lxml I get the following. :(
    – kRazzy R
    Jul 17, 2018 at 16:15
  • @kRazzyR try to run sudo apt-get install python-lxml command Jul 11, 2019 at 6:27
4

In my case the command sudo apt-get install unixodbc-dev resolved the issue. I was getting an error specific to the sql.h header file.

3
  • 1
    This was the same issue I was facing i.e. "an error specific to the sql.h header file" and this solution worked!
    – Eric
    Sep 9, 2021 at 15:41
  • 1
    Yes i had the same issue , this worked fine for me Dec 28, 2021 at 8:30
  • 1
    Yep that was the only thing I needed too!
    – almanegra
    Mar 29, 2022 at 10:23
3

Tip: Please do not consider this as an answer. Just to help someone else too.

I had similar issue while installing psycopg2. I installedbuild-essential, python-dev and also libpq-dev but it thrown same error.

error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

As I was in hurry in deployment so finally just copied full line from @user3440631's answer.

sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev

And It worked like a charm. but could not find which package has resolved my issue. Please update the comment if anyone have idea about psycopg2 dependancy package from above command.

1
  • 2
    I have solved my psycopg2 problem by installing postgresql-devel package on CentOS.
    – Phyticist
    Jan 28, 2017 at 16:10
3
sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev

sudo easy_install greenlet

sudo easy_install gevent
3
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Lot of time I got the same error when installing M2Crypto & pygraphviz and installed all the things mention in the approved answer. But this below line solved all my problems with the other packages in approved answer too.

sudo apt-get install libssl-dev swig
sudo apt-get install -y graphviz-dev

This swig package saved my life as the solution for M2Crypto and graphviz-dev for pygraphviz. I hope this will help someone.

2

For me I had to make sure I was using the correct version of cryptography. pip.freeze had and older version and once I used the latest the problem when away.

2

For Centos 7 Use below command to install Python Development Package

Python 2.7

sudo yum install python-dev

Python 3.4

sudo yum install python34-devel

Still if your problem not solved then try installing below packages -

sudo yum install libffi-devel

sudo yum install openssl-devel

1

None of the above answers worked for me when I had the same issue on my Ubuntu 14.04

However, this solved the error:

sudo apt-get install python-numpy libicu-dev

2
  • Odoo don't depend on python-numpy.
    – Kenly
    Oct 28, 2016 at 13:58
  • This is the only solution worked for me in Ubuntu 16.04 Jan 23, 2017 at 19:53
1

For me it helped to install libxml2-dev and libxslt1-dev.

sudo apt-get install libxml2-dev
1

My stack was like that:

> >                            ^
> >     In file included from /usr/include/openssl/ssl.h:156:0,
> >                      from OpenSSL/crypto/x509.h:17,
> >                      from OpenSSL/crypto/crypto.h:17,
> >                      from OpenSSL/crypto/crl.c:3:
> >     /usr/include/openssl/x509.h:751:15: note: previous declaration of ‘X509_REVOKED_dup’ was here
> >      X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);
> >                    ^
> >     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
> >     
> >     ----------------------------------------   Rolling back uninstall of > pyOpenSSL Command "/home/marta/env/pb/bin/python -u -c
> "import setuptools,
> > tokenize;__file__='/tmp/pip-build-14ekWY/pyOpenSSL/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-2HERvW-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/marta/env/pb/include/site/python2.7/pyOpenSSL" failed with error
> > code 1 in /tmp/pip-build-14ekWY/pyOpenSSL/

in the same case, please consider the typo (bug) in one of the installation files and edit it manually by changing "X509_REVOKED_dup" to "X509_REVOKED_dupe" (no quotes). I have edited the x509.h file:

sed -e's/X509_REVOKED_dup/X509_REVOKED_dupe/g' -i usr/include/openssl/x509.h

and it worked for me, but please consult with the post linked below, as they edited another file:

sed -e's/X509_REVOKED_dup/X509_REVOKED_dupe/g' -i OpenSSL/crypto/crl.c

https://groups.google.com/forum/#!topic/kivy-users/Qt0jNIOACZc

1

Like Robin Winslow says in a comment :

I found my solution over here: stackoverflow.com/a/5178444/613540

In my case, my complete error message was :

/usr/bin/ld: cannot find -lz 
collect2: error: ld returned 1 exit status
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I was trying to install torrench :

sudo python3 setup.py install

With given stackoverflow link, I solve this issue by :

sudo apt install zlib1g-dev

Note that the following packages were already installed :

libxslt1-dev is already the newest version.
python3-dev is already the newest version.
libxml2-dev is already the newest version.

Hope that will help !

Not the answer you're looking for? Browse other questions tagged or ask your own question.