Python - 命令 "python setup.py egg_info" 在 /tmp/pip-build-21ft0H/pandas 中失败,错误代码为 1

Python - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-21ft0H/pandas

我正在使用 Centos 7 和 Python 2.7.5。问题是当我安装 Pandas 时,我收到此错误消息

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-21ft0H/pandas

我已经尝试了很多解决方案,但甚至都没有成功 yum -y update

我已经找到答案了。我需要通过 RPM 安装 python。

rpm -i ftp://195.220.108.108/linux/centos/7.1.1503/updates/x86_64/Packages/python-2.7.5-18.el7_1.1.x86_64.rpm

参考:http://blog.revivalx.com/2015/11/14/python-command-python-setup-py-egg_info-failed-with-error-code-1-tmppip-build-21ft0hpandas/

从 0.7 版开始,Distribute 已合并到 Setuptools 中。如果您使用的版本 <=0.6,请使用 pip install --upgrade setuptoolseasy_install -U setuptools.

升级

关注 link 解决了我的问题

https://googleapis/google-cloud-python#3884

您应该尝试 pip install --upgrade setuptools。

sudo apt-get install python-matplotlib

我在 matplotlib 安装过程中遇到类似错误时使用了这个

只需执行这条命令:

sudo apt-get install python3.6-dev libmysqlclient-dev

以我的持续集成工作为例:

before_script:
  - apk update && apk add python3-dev
  - apk add --no-cache python3-dev libstdc++
  - apk add --update curl gcc g++
  - ln -s /usr/include/locale.h /usr/include/xlocale.h
  - pip3 install numpy
  - pip3 install pandas
  - rm -rf /var/cache/apk/*
  - python -V
  - python -m pip install --upgrade pip
  - python -m pip install --upgrade pip setuptools wheel --user --no-cache-dir

我从 pip3 安装 mysqlclient 时遇到这个错误

所以我执行了命令:

sudo apt-get install python3.6-dev libmysqlclient-dev

执行此命令后,我能够成功安装 mysqlclient

注意:- 版本号 3.6 将替换为您的 python 版本

pip install -- upgrade pip python -m pip install pandas