安装脚本退出并出现错误:命令 ‘x86_64-linux-gnu-gcc’ 失败,退出状态为 1
Setup script exited with error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
要解决“安装脚本退出时出现错误:命令‘x86_64-linux-gnu-gcc’失败,退出状态为 1”错误,请在运行命令之前安装python-dev
软件包pip install
。
打开终端并运行适合您的操作系统和包管理器的命令。
壳
# 👇️ 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
该命令会安装适合您的 Python 版本的静态库和头文件。
如果这没有帮助,您必须安装python3-dev
特定版本的 Python。
首先使用该python --version
命令获取您的 Python 版本。
壳
python --version
例如,我的 Python 版本是 3.11,因此我将python-dev
包的范围限定为 Python 3.11
。
壳
sudo apt install python3.11-dev build-essential gcc
如果您的 Python 版本是3.10
,您将运行以下命令。
壳
# 👇️ python3.10 sudo apt install python3.10-dev build-essential gcc
如果您的 Python 版本是 3.8,则需要安装python3.8-dev
.
壳
# 👇️ python3.8 sudo apt install python3.8-dev build-essential gcc
安装缺少的依赖项和头文件
如果错误仍然存在,请安装以下软件包以确保安装了必要的开发库和头文件。
壳
sudo apt install libblas-dev libatlas-base-dev
如果错误仍然存在,请尝试安装lib*
软件包。
和包用于加密libssl-dev
。libffi-dev
壳
sudo apt install libssl-dev libffi-dev
和包用于处理 XML 和 HTML libxml2-dev
。libxslt1-dev
壳
sudo apt install libxml2-dev libxslt1-dev
提供libpq-dev
了用于编译 C 程序的头文件和静态库。
壳
sudo apt install libpq-dev libldap2-dev libsasl2-dev
更新你的版本pip
如果这没有帮助,请尝试
升级您的 pip 版本。
pip
以下是在所有操作系统上进行升级的命令。
哪个命令有效取决于您的操作系统和 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 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
升级 pip 后,
还要升级 setuptools 。
壳
pip install --upgrade setuptools pip3 install --upgrade setuptools python3 -m pip install --upgrade setuptools py -m pip install --upgrade setuptools
安装python3.X-dev
和软件包并升级版本后
,错误应该会得到解决。lib*
pip