Last updated: Apr 9, 2024
Reading timeยท3 min
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.
# ๐๏ธ 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
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.
python --version
For example, my Python version is 3.11, so I'd scope the python-dev
package to
Python 3.11
.
sudo apt install python3.11-dev build-essential gcc
If your Python version is 3.10
, you would run the following commands.
# ๐๏ธ python3.10 sudo apt install python3.10-dev build-essential gcc
If your Python version is 3.8, you'd install python3.8-dev
.
# ๐๏ธ python3.8 sudo apt install python3.8-dev build-essential gcc
If the error persists, install the following packages to make sure you have the necessary development libraries and header files installed.
sudo apt install libblas-dev libatlas-base-dev
If the error persists, try installing the lib*
packages.
The libssl-dev
and libffi-dev
packages are used for cryptography.
sudo apt install libssl-dev libffi-dev
The libxml2-dev
and libxslt1-dev
packages are used for processing XML and
HTML.
sudo apt install libxml2-dev libxslt1-dev
The libpq-dev
provides header files and a static library for compiling C
programs.
sudo apt install libpq-dev libldap2-dev libsasl2-dev
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.
# ๐๏ธ 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.
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.