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

avatar
Borislav Hadzhiev

Last updated: Apr 9, 2024
3 min

banner

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

To solve the "Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1" error, install the python-dev package before running the pip install command.

Open your terminal and run the command that is suitable for your operating system and package manager.

shell
# ๐Ÿ‘‡๏ธ for Debian (Ubuntu) sudo apt install python-dev build-essential gcc # python2.x sudo apt install python3-dev build-essential gcc # python3.x # ๐Ÿ‘‡๏ธ for Redhat/CentOS sudo yum install python-devel # python2.x sudo yum install python3-devel # python3.x # ๐Ÿ‘‡๏ธ for Alpine Linux sudo apk add python2-dev # python2.x sudo apk add python3-dev # python3.x # ๐Ÿ‘‡๏ธ for openSUSE sudo zypper in python-devel # python2.x sudo zypper in python3-devel # python3.x # ๐Ÿ‘‡๏ธ for Cygwin apt-cyg install python-devel # for python2.x apt-cyg install python3-devel # for python3.x

install python3 dev

The command installs the static library and header files for your version of Python.

If that didn't help, you have to install python3-dev for your specific version of Python.

Use the python --version command to get your version of Python first.

shell
python --version

get python version

For example, my Python version is 3.11, so I'd scope the python-dev package to Python 3.11.

shell
sudo apt install python3.11-dev build-essential gcc

install python dev specific version

If your Python version is 3.10, you would run the following commands.

shell
# ๐Ÿ‘‡๏ธ python3.10 sudo apt install python3.10-dev build-essential gcc

If your Python version is 3.8, you'd install python3.8-dev.

shell
# ๐Ÿ‘‡๏ธ python3.8 sudo apt install python3.8-dev build-essential gcc

# Install missing dependencies and header files

If the error persists, install the following packages to make sure you have the necessary development libraries and header files installed.

shell
sudo apt install libblas-dev libatlas-base-dev

install libblas dev

If the error persists, try installing the lib* packages.

The libssl-dev and libffi-dev packages are used for cryptography.

shell
sudo apt install libssl-dev libffi-dev

install libssl dev

The libxml2-dev and libxslt1-dev packages are used for processing XML and HTML.

shell
sudo apt install libxml2-dev libxslt1-dev

The libpq-dev provides header files and a static library for compiling C programs.

shell
sudo apt install libpq-dev libldap2-dev libsasl2-dev

install libxml2 dev

# Update your version of pip

If that didn't help, try upgrading your version of pip.

Here are the commands for upgrading pip on all operating systems.

Which command works depends on your operating system and your version of Python.

shell
# ๐Ÿ‘‡๏ธ If you have pip already installed pip install --upgrade pip # ๐Ÿ‘‡๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade pip # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python3 -m pip install --upgrade pip # ๐Ÿ‘‡๏ธ If you have easy_install easy_install --upgrade pip # ๐Ÿ‘‡๏ธ If you get a permissions error sudo easy_install --upgrade pip # ๐Ÿ‘‡๏ธ If you get a permissions error when upgrading pip pip install --upgrade pip --user # ๐Ÿ‘‡๏ธ Upgrade pip scoped to the current user (if you get a permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # ๐Ÿ‘‡๏ธ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # ๐Ÿ‘‡๏ธ If you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # ๐Ÿ‘‡๏ธ Alternative for Ubuntu/Debian sudo apt-get update && apt-get upgrade python-pip # ๐Ÿ‘‡๏ธ Alternative for Red Hat/CentOS/Fedora sudo yum install epel-release sudo yum install python-pip sudo yum update python-pip

After you upgrade pip, upgrade setuptools as well.

shell
pip install --upgrade setuptools pip3 install --upgrade setuptools python3 -m pip install --upgrade setuptools py -m pip install --upgrade setuptools

Once the python3.X-dev and lib* packages are installed and your pip version is upgraded, the error should be resolved.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev