python中与six有关的whl_pandas - 在升级numpy,six和python-dateutil时,无法使用pip来安装pandas - 堆栈内存溢出...

徐卓
2023-12-01

在升级numpy和pytho-dateutil我无法使用pip来安装pandas 。 经过几次尝试,我认为问题在于pip默认安装路径。 如何解决此问题并成功安装pandas ?

Python 2.7已经安装在我的Mac上,当我想import pandas ,我注意到一条错误消息,建议将python-dateuntil升级到2.5.0。

>>> import pandas

Traceback (most recent call last):

File "", line 1, in

File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 23, in

from pandas.compat.numpy import *

File "/Library/Python/2.7/site-packages/pandas/compat/__init__.py", line 438, in

raise ImportError('dateutil 2.5.0 is the minimum required version')

ImportError: dateutil 2.5.0 is the minimum required version

所以我使用pip来升级python-dateutil但是尝试失败了:

我升级了dateutil,但发现了升级six numpy的问题。

$ pip install --upgrade python-dateutil

Collecting python-dateutil

Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl

Collecting six>=1.5 (from python-dateutil)

Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl

ERROR: pandas 0.24.2 has requirement numpy>=1.12.0, but you'll have numpy 1.8.0rc1 which is incompatible.

Installing collected packages: six, python-dateutil

Found existing installation: six 1.4.1

ERROR: Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

所以我尝试先升级six numpy 。 但是,在安装numpy时遇到了PATH问题。

$ pip install --upgrade --ignore-installed numpy --user

Collecting numpy

Using cached https://files.pythonhosted.org/packages/8f/0b/1a2c21bb69138337dc079841aa4a45e5b2fc7a4260c0907f5254fb08f02e/numpy-1.16.4-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

ERROR: pandas 0.24.2 has requirement python-dateutil>=2.5.0, but you'll have python-dateutil 1.5 which is incompatible.

Installing collected packages: numpy

WARNING: The scripts f2py, f2py2 and f2py2.7 are installed in '/Users/myname/Library/Python/2.7/bin' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed numpy-1.16.4

$ pip install --upgrade --ignore-installed six --user

Collecting six

Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl

Installing collected packages: six

Successfully installed six-1.12.0

如果numpy和six更新,请检查pip 。 似乎six numpy的版本仍然是旧版本。

$ pip show numpy

Name: numpy

Version: 1.8.0rc1

Summary: NumPy: array processing for numbers, strings, records, and objects.

Home-page: http://www.numpy.org

Author: NumPy Developers

Author-email: numpy-discussion@scipy.org

License: BSD

Location: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Requires:

Required-by: pypanda, matplotlib, pandas

$ pip show six

Name: six

Version: 1.4.1

Summary: Python 2 and 3 compatibility utilities

Home-page: http://pypi.python.org/pypi/six/

Author: Benjamin Peterson

Author-email: benjamin@python.org

License: UNKNOWN

Location: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Requires:

Required-by: singledispatch

我试图忽略six numpy来安装pandas 。 我发现pandas可以安装但位于另一个与numpy和six不同的目录中。

$ pip install pandas --ignore-installed numpy six --user

Collecting pandas

Using cached https://files.pythonhosted.org/packages/52/ff/912fe03a623a70bcf297d466013a0b4f4c68c3b60f86bf226682d061fc09/pandas-0.24.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

Collecting numpy

Using cached https://files.pythonhosted.org/packages/8f/0b/1a2c21bb69138337dc079841aa4a45e5b2fc7a4260c0907f5254fb08f02e/numpy-1.16.4-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

Collecting six

Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl

Collecting pytz>=2011k (from pandas)

Using cached https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl

Collecting python-dateutil>=2.5.0 (from pandas)

Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl

Installing collected packages: numpy, pytz, six, python-dateutil, pandas

WARNING: The scripts f2py, f2py2 and f2py2.7 are installed in '/Users/myname/Library/Python/2.7/bin' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed numpy-1.16.4 pandas-0.24.2 python-dateutil-2.8.0 pytz-2019.1 six-1.12.0

$ pip show pandas

Name: pandas

Version: 0.24.2

Summary: Powerful data structures for data analysis, time series, and statistics

Home-page: http://pandas.pydata.org

Author: None

Author-email: None

License: BSD

Location: /Library/Python/2.7/site-packages

Requires: numpy, pytz, python-dateutil

Required-by: pypanda

鉴于上面的错误消息,即使我无法完全理解这两个目录的关系 - /Library/Python/2.7/site-packages /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python和/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python ,哪一个应该是正确的python库安装目录? 我在想我的问题在于pip默认安装位置,但我不知道如何解决这个问题。 我期望在没有任何python替换的情况下解决这个问题,例如python3或python虚拟环境。

提前致谢!

 类似资料: