如何修复Python Numpy/熊猫的安装?

时间:2022-11-07 19:30:45

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6.

我想在Mac OS X 10.6.8上安装Python熊猫库(0.8.1)。这个图书馆需要Numpy > = 1.6。

I tried this

我试着这

$ 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

So I tried to install Numpy

所以我尝试安装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

So I tried again

所以我再次尝试

$ sudo easy_install pandas

But the problem is still the same !

但问题还是一样!

error: Setup script exited with pandas requires NumPy >= 1.6 due to datetime64 dependency

I run Python

我运行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'

So Numpy 1.6 doesn't seems to be installed correctly !

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

I tried to install Numpy 1.6 with pip (instead of easy_install)...

我尝试用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...

I added --upgrade flag

我补充说,升级国旗

$ 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

I also tried to install binary version of Numpy http://sourceforge.net/projects/numpy/files/ numpy-1.6.2-py2.6-python.org-macosx10.3.dmg but it fails !!! (installer said me that numpy 1.6.2 can't be install on this disk. Numpy requires python.org Python 2.6 to install.

我还试着安装二进制版本的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安装。

9 个解决方案

#1


42  

Don't know if you solved the problem but if anyone has this problem in future.

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

$python
>>import numpy
>>print(numpy)

Go to the location printed and delete the numpy installation found there. You can then use pip or easy_install

到打印的位置,删除在那里找到的numpy安装。然后可以使用pip或easy_install。

#2


8  

I had this exact problem.

我有个问题。

The issue is that there is an old version of numpy in the default mac install, and that pip install pandas sees that one first and fails -- not going on to see that there is a newer version that pip herself has installed.

问题是在默认的mac安装中有一个旧版本的numpy,而pip安装了熊猫看到的是第一个和失败的,没有看到有一个新的版本,pip自己已经安装。

If you're on a default mac install, and you've done pip install numpy --upgrade to be sure you're up to date, but pip install pandas still fails due to an old numpy, try the following:

如果你在一个默认的mac安装上,并且你已经做了pip安装numpy——升级到确定你是最新的,但是pip安装的熊猫仍然失败,由于一个旧的numpy,尝试以下:

$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
$ sudo rm -r numpy
$ pip install pandas

This should now install / build pandas.

现在应该安装熊猫了。

To check it out what we've done, do the following: start python, and import numpy and import pandas. With any luck, numpy.__version__ will be 1.6.2 (or greater), and pandas.__version__ will be 0.9.1 (or greater).

要查看我们所做的工作,请执行以下操作:启动python,导入numpy并导入熊猫。运气好的话,numpy。__version__将为1.6.2(或更大)和熊猫。__version__将是0.9.1(或更大)。

If you'd like to see where pip has put (found!) them, just print(numpy) and print(pandas).

如果你想看看pip在哪里找到(找到了!)它们,只打印(numpy)和打印(熊猫)。

#3


7  

I work with the guys that created Anaconda Python. You can install multiple versions of python and numpy without corrupting your system python. It's free and open source (OSX, linux, Windows). The paid packages are enhancements on top of the free version. Pandas is included.

我和制作蟒蛇的家伙一起工作。您可以安装多个版本的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

If you want numpy 1.6:

如果你想要numpy 1.6:

conda create --name np16py27 anaconda=1.4 numpy=1.6 python=2.7

Setting your PATH sets up where to find python and ipython. The environments (np17py27) can be named whatever you would like.

设置路径设置在哪里可以找到python和ipython。环境(np17py27)可以命名为任何您想要的名称。

#4


5  

This worked for me under 10.7.5 with EPD_free-7.3-2 from Enthought:

这对我来说是在10.7.5以下,EPD_free-7.3-2来自Enthought:

Install EPD free, then follow the step in the following link to create .bash_profile file.

安装EPD免费,然后按照下面的步骤创建.bash_profile文件。

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

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

And add the following to the file.

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

PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$(PATH)}"
export PATH

Execute the following command in Terminal

在终端执行以下命令。

$ sudo easy_install pandas

When finished, launch PyLab and type:

完成后,发射PyLab并输入:

In [1]: import pandas

In [2]: plot(arange(10))

This should open a plot with a diagonal straight line.

这应该用一条对角线的直线来打开一个图。

#5


4  

If you're like me and you don't like the idea of deleting things that were part of the standard system installation (which others have suggested) then you might like the solution I ended up using:

如果你像我一样,你不喜欢删除标准系统安装的一部分(其他人建议的),那么你可能会喜欢我最后使用的解决方案:

  1. Get Homebrew - it's a one-line shell script to install!
  2. Get Homebrew -它是一个单行shell脚本安装!
  3. Edit your .profile, or whatever is appropriate, and put /usr/local/bin at the start of your PATH so that Homebrew binaries are found before system binaries
  4. 编辑您的.profile,或者其他合适的,并将/usr/local/bin放在您的路径的开头,以便在系统二进制文件之前找到自制的二进制文件。
  5. brew install python - this installs a newer version of python in /usr/local
  6. brew安装python -这安装了python在/usr/local中的更新版本。
  7. pip install pandas
  8. pip安装熊猫

This worked for me in OS X 10.8.2, and I can't see any reason it shouldn't work in 10.6.8.

这在OS X 10.8.2中为我工作,我看不出它为什么不能在10.6.8中工作。

#6


3  

I had the same problem and, in my case, the problem was that python was looking for packages in some ordered locations, first of all the default computer one where default old packages are.

我遇到了同样的问题,在我的例子中,问题是python在一些有序的位置寻找包,首先是默认的计算机,默认的旧包在那里。

To check what your python is looking for you can do:

要检查您的python正在寻找什么,您可以这样做:

>>> import sys
>>> print '\n'.join(sys.path)

This was outputting the directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' before pip or brew or port folders.

在pip或brew或端口文件夹之前,这是输出目录'/系统/库/框架/python /python /版本/2.7/Extras/lib/python'。

The simple solution is:

一个简单的解决方案是:

export PYTHONPATH="/Library/Python/2.7/site-packages:$PYTHONPATH"

This worked well for me, I advise you to add this line to your home bash_profile file for the next time. Remember that sys.path is built using the current working directory, followed by the directories in the PYTHONPATH environment variable. Then there are the installation-dependent default dirs.

这对我很有效,我建议您下次将这一行添加到您的home bash_profile文件中。记住系统。path是使用当前工作目录构建的,然后是PYTHONPATH环境变量中的目录。然后是与安装相关的默认dirs。

#7


2  

You probably have another Numpy version installed on your system, try to query your numpy version and retrieve it if your distribution does not support it.
aka debian/unbuntu/Mint version can query mostly from dpkg package manger : dpkg --get-selections | egrep -i "numpy", you can see actual Numpy version.

您可能在您的系统上安装了另一个Numpy版本,尝试查询您的Numpy版本,如果您的发行版不支持它,就检索它。debian/unbuntu/Mint版本的查询主要来自dpkg包装的manger: dpkg -选择|白种-我“numpy”,您可以看到实际的numpy版本。

  • Some having apt can either asking to removing it by doing this: apt-get remove numpy.

    有些apt可以通过这样做来删除它:apt-get移除numpy。

  • Some having distribution like Fedora, RedHat and any compatible release under RedHat model can use rpm as well to query the installation.

    一些具有像Fedora、RedHat和RedHat模型中任何兼容版本的发行版都可以使用rpm来查询安装。

  • This is happening by telling to Numpy installer to install itself in current /usr/local/lib/python[VERSION]/dist-packages over Linux env and c:[...]\python[VERSION]\site-packages for windows. Having probably One version of Numpy installed in /usr/local/python[VERSION]/dist-packages, this one will be instantiated first.

    这是通过告诉Numpy安装程序在当前/usr/local/lib/python[版本]/在Linux env和c:[…python(版)\]\ windows的网站。在/usr/local/python[version]/dist-package中安装了一个版本的Numpy,这个版本将首先被实例化。

  • .pth file hold information about path location of specific python module, but erasing a component from packages may corrupt it...
  • .pth文件保存有关特定python模块的路径位置的信息,但是清除包中的组件可能会损坏它……

Be careful, and you will have to remove the package and all it's dependency... really painful in some case.

要小心,您必须删除包和所有它的依赖…在某些情况下真的很痛苦。

Visiting lunchad.net may save you time sometimes they had new versions from some packages.

访问午餐。net可能会节省你的时间,有时他们有一些新的版本。

#8


2  

If you are using a version of enthought python (EPD) you might want to go directly to your site-packages and reinstall numpy. Then try to install pandas with pip. You will have to modify your installation prefix for that.

如果您使用的是enthought python (EPD)版本,您可能想直接访问站点包并重新安装numpy。然后试着用匹普装熊猫。您需要修改安装前缀。

If the problem persists (as it did with me) try downloading pandas tar ball, unpack it in your site packages and run setup.py install from your pandas directory.

如果问题仍然存在(就像我一样),试着下载熊猫焦油球,在你的网站包中打开它,然后运行安装程序。py安装从您的熊猫目录。

If you got your dependencies right you can import pandas and check it imports smoothly.

如果你的属相是正确的,你可以进口熊猫并顺利进口。

#9


1  

he easiest way to install Pandas, like almost every other package for Python, is with pip.

他最简单的方法就是用pip来安装熊猫,就像其他的Python包一样。

Many packages (including Pandas) require a compiler, and a bunch of third-party DLLs, and many Windows users don't know how to deal with that. That's exactly why the "wheel" format was created: so packages can upload pre-built binaries.

许多包(包括熊猫)需要一个编译器,还有一些第三方dll,许多Windows用户不知道如何处理这些。这就是为什么要创建“wheel”格式的原因:所以包可以上传预构建的二进制文件。

Not every project has pre-built binary wheels for Windows yet. But you can look at Christoph Gohlke's site and find wheels for all of the most popular ones. Just follow the instructions on that page to download the wheel file and install it with pip.

并不是每一个项目都有针对Windows的预构建的二进制车轮。但你可以看看Christoph Gohlke的网站,找到所有最受欢迎的网站的*。只需按照该页面上的说明下载该轮文件,并将其安装到pip中。

But in the case of Pandas, you don't have to do that. They have wheels on their download page, and uploaded to PyPI. And the documentation tells you to use these. (Well, it first suggests you use Anaconda/Miniconda, but if you want a stock Python, use pip and the packages on PyPI.) it worked for me ...on windows 7 64 bit ,python 3.4

但就熊猫而言,你不必这么做。他们的下载页面上有*,上传到PyPI。文档告诉你使用这些。(嗯,它首先建议你使用Anaconda/Miniconda,但如果你想要一个股票Python,可以使用pip和PyPI上的包)。在windows 7 64位上,python 3.4。

#1


42  

Don't know if you solved the problem but if anyone has this problem in future.

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

$python
>>import numpy
>>print(numpy)

Go to the location printed and delete the numpy installation found there. You can then use pip or easy_install

到打印的位置,删除在那里找到的numpy安装。然后可以使用pip或easy_install。

#2


8  

I had this exact problem.

我有个问题。

The issue is that there is an old version of numpy in the default mac install, and that pip install pandas sees that one first and fails -- not going on to see that there is a newer version that pip herself has installed.

问题是在默认的mac安装中有一个旧版本的numpy,而pip安装了熊猫看到的是第一个和失败的,没有看到有一个新的版本,pip自己已经安装。

If you're on a default mac install, and you've done pip install numpy --upgrade to be sure you're up to date, but pip install pandas still fails due to an old numpy, try the following:

如果你在一个默认的mac安装上,并且你已经做了pip安装numpy——升级到确定你是最新的,但是pip安装的熊猫仍然失败,由于一个旧的numpy,尝试以下:

$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
$ sudo rm -r numpy
$ pip install pandas

This should now install / build pandas.

现在应该安装熊猫了。

To check it out what we've done, do the following: start python, and import numpy and import pandas. With any luck, numpy.__version__ will be 1.6.2 (or greater), and pandas.__version__ will be 0.9.1 (or greater).

要查看我们所做的工作,请执行以下操作:启动python,导入numpy并导入熊猫。运气好的话,numpy。__version__将为1.6.2(或更大)和熊猫。__version__将是0.9.1(或更大)。

If you'd like to see where pip has put (found!) them, just print(numpy) and print(pandas).

如果你想看看pip在哪里找到(找到了!)它们,只打印(numpy)和打印(熊猫)。

#3


7  

I work with the guys that created Anaconda Python. You can install multiple versions of python and numpy without corrupting your system python. It's free and open source (OSX, linux, Windows). The paid packages are enhancements on top of the free version. Pandas is included.

我和制作蟒蛇的家伙一起工作。您可以安装多个版本的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

If you want numpy 1.6:

如果你想要numpy 1.6:

conda create --name np16py27 anaconda=1.4 numpy=1.6 python=2.7

Setting your PATH sets up where to find python and ipython. The environments (np17py27) can be named whatever you would like.

设置路径设置在哪里可以找到python和ipython。环境(np17py27)可以命名为任何您想要的名称。

#4


5  

This worked for me under 10.7.5 with EPD_free-7.3-2 from Enthought:

这对我来说是在10.7.5以下,EPD_free-7.3-2来自Enthought:

Install EPD free, then follow the step in the following link to create .bash_profile file.

安装EPD免费,然后按照下面的步骤创建.bash_profile文件。

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

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

And add the following to the file.

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

PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$(PATH)}"
export PATH

Execute the following command in Terminal

在终端执行以下命令。

$ sudo easy_install pandas

When finished, launch PyLab and type:

完成后,发射PyLab并输入:

In [1]: import pandas

In [2]: plot(arange(10))

This should open a plot with a diagonal straight line.

这应该用一条对角线的直线来打开一个图。

#5


4  

If you're like me and you don't like the idea of deleting things that were part of the standard system installation (which others have suggested) then you might like the solution I ended up using:

如果你像我一样,你不喜欢删除标准系统安装的一部分(其他人建议的),那么你可能会喜欢我最后使用的解决方案:

  1. Get Homebrew - it's a one-line shell script to install!
  2. Get Homebrew -它是一个单行shell脚本安装!
  3. Edit your .profile, or whatever is appropriate, and put /usr/local/bin at the start of your PATH so that Homebrew binaries are found before system binaries
  4. 编辑您的.profile,或者其他合适的,并将/usr/local/bin放在您的路径的开头,以便在系统二进制文件之前找到自制的二进制文件。
  5. brew install python - this installs a newer version of python in /usr/local
  6. brew安装python -这安装了python在/usr/local中的更新版本。
  7. pip install pandas
  8. pip安装熊猫

This worked for me in OS X 10.8.2, and I can't see any reason it shouldn't work in 10.6.8.

这在OS X 10.8.2中为我工作,我看不出它为什么不能在10.6.8中工作。

#6


3  

I had the same problem and, in my case, the problem was that python was looking for packages in some ordered locations, first of all the default computer one where default old packages are.

我遇到了同样的问题,在我的例子中,问题是python在一些有序的位置寻找包,首先是默认的计算机,默认的旧包在那里。

To check what your python is looking for you can do:

要检查您的python正在寻找什么,您可以这样做:

>>> import sys
>>> print '\n'.join(sys.path)

This was outputting the directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' before pip or brew or port folders.

在pip或brew或端口文件夹之前,这是输出目录'/系统/库/框架/python /python /版本/2.7/Extras/lib/python'。

The simple solution is:

一个简单的解决方案是:

export PYTHONPATH="/Library/Python/2.7/site-packages:$PYTHONPATH"

This worked well for me, I advise you to add this line to your home bash_profile file for the next time. Remember that sys.path is built using the current working directory, followed by the directories in the PYTHONPATH environment variable. Then there are the installation-dependent default dirs.

这对我很有效,我建议您下次将这一行添加到您的home bash_profile文件中。记住系统。path是使用当前工作目录构建的,然后是PYTHONPATH环境变量中的目录。然后是与安装相关的默认dirs。

#7


2  

You probably have another Numpy version installed on your system, try to query your numpy version and retrieve it if your distribution does not support it.
aka debian/unbuntu/Mint version can query mostly from dpkg package manger : dpkg --get-selections | egrep -i "numpy", you can see actual Numpy version.

您可能在您的系统上安装了另一个Numpy版本,尝试查询您的Numpy版本,如果您的发行版不支持它,就检索它。debian/unbuntu/Mint版本的查询主要来自dpkg包装的manger: dpkg -选择|白种-我“numpy”,您可以看到实际的numpy版本。

  • Some having apt can either asking to removing it by doing this: apt-get remove numpy.

    有些apt可以通过这样做来删除它:apt-get移除numpy。

  • Some having distribution like Fedora, RedHat and any compatible release under RedHat model can use rpm as well to query the installation.

    一些具有像Fedora、RedHat和RedHat模型中任何兼容版本的发行版都可以使用rpm来查询安装。

  • This is happening by telling to Numpy installer to install itself in current /usr/local/lib/python[VERSION]/dist-packages over Linux env and c:[...]\python[VERSION]\site-packages for windows. Having probably One version of Numpy installed in /usr/local/python[VERSION]/dist-packages, this one will be instantiated first.

    这是通过告诉Numpy安装程序在当前/usr/local/lib/python[版本]/在Linux env和c:[…python(版)\]\ windows的网站。在/usr/local/python[version]/dist-package中安装了一个版本的Numpy,这个版本将首先被实例化。

  • .pth file hold information about path location of specific python module, but erasing a component from packages may corrupt it...
  • .pth文件保存有关特定python模块的路径位置的信息,但是清除包中的组件可能会损坏它……

Be careful, and you will have to remove the package and all it's dependency... really painful in some case.

要小心,您必须删除包和所有它的依赖…在某些情况下真的很痛苦。

Visiting lunchad.net may save you time sometimes they had new versions from some packages.

访问午餐。net可能会节省你的时间,有时他们有一些新的版本。

#8


2  

If you are using a version of enthought python (EPD) you might want to go directly to your site-packages and reinstall numpy. Then try to install pandas with pip. You will have to modify your installation prefix for that.

如果您使用的是enthought python (EPD)版本,您可能想直接访问站点包并重新安装numpy。然后试着用匹普装熊猫。您需要修改安装前缀。

If the problem persists (as it did with me) try downloading pandas tar ball, unpack it in your site packages and run setup.py install from your pandas directory.

如果问题仍然存在(就像我一样),试着下载熊猫焦油球,在你的网站包中打开它,然后运行安装程序。py安装从您的熊猫目录。

If you got your dependencies right you can import pandas and check it imports smoothly.

如果你的属相是正确的,你可以进口熊猫并顺利进口。

#9


1  

he easiest way to install Pandas, like almost every other package for Python, is with pip.

他最简单的方法就是用pip来安装熊猫,就像其他的Python包一样。

Many packages (including Pandas) require a compiler, and a bunch of third-party DLLs, and many Windows users don't know how to deal with that. That's exactly why the "wheel" format was created: so packages can upload pre-built binaries.

许多包(包括熊猫)需要一个编译器,还有一些第三方dll,许多Windows用户不知道如何处理这些。这就是为什么要创建“wheel”格式的原因:所以包可以上传预构建的二进制文件。

Not every project has pre-built binary wheels for Windows yet. But you can look at Christoph Gohlke's site and find wheels for all of the most popular ones. Just follow the instructions on that page to download the wheel file and install it with pip.

并不是每一个项目都有针对Windows的预构建的二进制车轮。但你可以看看Christoph Gohlke的网站,找到所有最受欢迎的网站的*。只需按照该页面上的说明下载该轮文件,并将其安装到pip中。

But in the case of Pandas, you don't have to do that. They have wheels on their download page, and uploaded to PyPI. And the documentation tells you to use these. (Well, it first suggests you use Anaconda/Miniconda, but if you want a stock Python, use pip and the packages on PyPI.) it worked for me ...on windows 7 64 bit ,python 3.4

但就熊猫而言,你不必这么做。他们的下载页面上有*,上传到PyPI。文档告诉你使用这些。(嗯,它首先建议你使用Anaconda/Miniconda,但如果你想要一个股票Python,可以使用pip和PyPI上的包)。在windows 7 64位上,python 3.4。