如何修复Python Numpy/Pandas安装?

scl*_*cls 29 python numpy pip easy-install pandas

我想在Mac OS X 10.6.8上安装Python Pandas库(0.8.1).这个库需要Numpy> = 1.6.

我试过这个

$ sudo easy_install pandas
Searching for pandas
Reading http://pypi.python.org/simple/pandas/
Reading http://pandas.pydata.org
Reading http://pandas.sourceforge.net
Best match: pandas 0.8.1
Downloading http://pypi.python.org/packages/source/p/pandas/pandas-0.8.1.zip#md5=d2c5c5bea971cd760b0ae6f6850fcb74
Processing pandas-0.8.1.zip
Running pandas-0.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ckAMym/pandas-0.8.1/egg-dist-tmp-0mlL7t
error: Setup script exited with pandas requires NumPy >= 1.6 due to datetime64 dependency
Run Code Online (Sandbox Code Playgroud)

所以我试着安装Numpy

$ sudo easy_install numpy
Searching for numpy
Best match: numpy 1.6.2
Adding numpy 1.6.2 to easy-install.pth file

Using /Library/Python/2.6/site-packages
Processing dependencies for numpy
Finished processing dependencies for numpy
Run Code Online (Sandbox Code Playgroud)

所以我又试了一次

$ sudo easy_install pandas
Run Code Online (Sandbox Code Playgroud)

但问题仍然是一样的!

error: Setup script exited with pandas requires NumPy >= 1.6 due to datetime64 dependency
Run Code Online (Sandbox Code Playgroud)

我运行Python

$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.2.1'
Run Code Online (Sandbox Code Playgroud)

所以Numpy 1.6似乎没有正确安装!

我尝试用pip(代替easy_install)安装Numpy 1.6 ...

$ sudo pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.6/site-packages
Cleaning up...
Run Code Online (Sandbox Code Playgroud)

我加了--upgrade旗子

$ sudo pip install numpy --upgrade
Requirement already up-to-date: numpy in /Library/Python/2.6/site-packages
Cleaning up...

$ sudo pip install pandas
Downloading/unpacking pandas
  Downloading pandas-0.8.1.zip (1.9MB): 1.9MB downloaded
  Running setup.py egg_info for package pandas
    pandas requires NumPy >= 1.6 due to datetime64 dependency
    Complete output from command python setup.py egg_info:
    pandas requires NumPy >= 1.6 due to datetime64 dependency

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/pandas
Storing complete log in /Users/MyUsername/Library/Logs/pip.log
Run Code Online (Sandbox Code Playgroud)

我也尝试安装Numpy的二进制版本http://sourceforge.net/projects/numpy/files/numpy-1.6.2-py2.6-python.org-macosx10.3.dmg 但它失败了!(安装程序说我不能在这个磁盘上安装numpy 1.6.2.Numpy需要安装python.org Python 2.6.

tr3*_*ous 47

不知道你是否解决了这个问题,但是如果有人将来遇到这个问题.

$python
>>import numpy
>>print(numpy)
Run Code Online (Sandbox Code Playgroud)

转到打印的位置并删除在numpy那里找到的安装.然后你可以使用pipeasy_install


ric*_*rdo 9

我有这个确切的问题.

问题是在默认的mac安装中有一个旧版本的numpy,并且pip install pandas首先看到它并且失败 - 没有继续看到有pip自己安装的更新版本.

如果您使用的是默认的mac安装,并且已经完成pip install numpy --upgrade以确保自己是最新版本,但pip install pandas仍然因旧版本而失败numpy,请尝试以下操作:

$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
$ sudo rm -r numpy
$ pip install pandas
Run Code Online (Sandbox Code Playgroud)

现在应该安装/构建pandas.

要查看我们已经完成的工作,请执行以下操作:启动python,import numpyimport pandas.运气好的话,numpy.__version__将是1.6.2(或更高),并且pandas.__version__将是0.9.1(或更高).

如果你想看看pip放在哪里(找到了!),那就print(numpy)print(pandas).

  • 删除/ System之外的东西是个坏主意. (2认同)

Bra*_*der 8

我和创建Anaconda Python的人一起工作.您可以安装多个版本的python和numpy而不会破坏您的系统python.它是免费和开源的(OSX,Linux,Windows).付费套餐是免费版本之上的增强功能.熊猫是包括在内的.

conda create --name np17py27 anaconda=1.4 numpy=1.7 python=2.7
export PATH=~/anaconda/envs/np17py27/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

如果你想要numpy 1.6:

conda create --name np16py27 anaconda=1.4 numpy=1.6 python=2.7
Run Code Online (Sandbox Code Playgroud)

设置PATH设置在哪里可以找到python和ipython.环境(np17py27)可以根据您的意愿命名.

  • 我和Anaconda以及多个版本的Python一起度过了一段糟糕的时光 - 它改变了我的默认python发行版并且在每个版本中搞乱了依赖项.我试着手动安装它. (2认同)

Tos*_*shi 5

根据Enthought的EPD_free-7.3-2,这对我来说在10.7.5下工作:

免费安装EPD,然后按照以下链接中的步骤创建.bash_profile文件.

http://redfinsolutions.com/blog/creating-bashprofile-your-mac

并将以下内容添加到文件中.

PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$(PATH)}"
export PATH
Run Code Online (Sandbox Code Playgroud)

在终端中执行以下命令

$ sudo easy_install pandas
Run Code Online (Sandbox Code Playgroud)

完成后,启动PyLab并输入:

In [1]: import pandas

In [2]: plot(arange(10))
Run Code Online (Sandbox Code Playgroud)

这应该打开一条带有对角直线的图.