Python Numpy从1.6更新到1.8 [英] Python numpy update from 1.6 to 1.8

查看:191
本文介绍了Python Numpy从1.6更新到1.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了numpy 1.8.但是,当我打印numpy.__version__时,它表示1.6.

I have installed numpy 1.8. But when I do print numpy.__version__ it says 1.6.

要使python意识到numpy在哪里,我必须更改什么?在Mac(10.9)上工作.我使用的是python 2.7.6.

What do I have to change to get python to realize where numpy is? Working on a Mac (10.9). I'm using python 2.7.6.

我尝试删除所有版本的numpy.我没有pip卸载numpy.然后我输入:

I've tried to delete all my versions of numpy. I did pip uninstall numpy. And then I typed:

python 导入numpy 打印numpy.版本

python import numpy print numpy.version

并打印出1.6.2

我显然不能删除numpy.

I can't delete numpy apparently.

推荐答案

我在Mac OS X 10.9.4上运行Python 2.7.5,这似乎是Macintosh出厂安装版本中某种怪异的错误.的Python正在处理升级的软件包安装.

I am running Python 2.7.5 on Mac OS X 10.9.4, and this appears to be some kind of weird bug in how the Macintosh factory-installed version of Python is handling upgraded package installations.

就我而言,当我这样做:

In my case, when I do:

sudo pip uninstall numpy

它删除安装在下面的numpy版本

it removes the version of numpy installed under

/Library/Python/2.7/site-packages

但是,这并不意味着numpy已从系统中完全删除!在以下位置还安装了一些Python软件包的第二组备份"版本:

However, this does not mean that numpy is fully removed from the system! There are a second set of "backup" versions of several Python packages installed also at:

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

当我使用Apple随OS X系统附带的/usr/bin/easy_install实用程序安装numpy时,将numpy的最新版本(当前为1.9.0,发布此信息)加载到Library/Python/2.7/site-packages中,就像一个期望,并且它正确地在模块加载路径中的numpy的"OS X系统默认"版本之前,以便当我在Python中执行import numpy时加载最新版本的numpy.但是-这是真正的怪异,显然是错误的行为!-当我卸载numpy时,而是使用pip或执行以下操作来重新安装:

When I install numpy using the /usr/bin/easy_install utility that Apple shipped with the OS X system, the latest version (currently at 1.9.0, as of this posting) of numpy is loaded into Library/Python/2.7/site-packages, just as one would expect, and it correctly precedes the "OS X system default" version of numpy in the module load path so that the latest version of numpy is loaded when I do import numpy in Python. However--and this is the really weird, apparently buggy behavior!--when I uninstall numpy, and instead reinstall using either pip, or by doing:

sudo python setup.py install

在直接从 sourceforge 下载的.tar.gz发行版中,升级后的安装不会在Python模块的加载路径中似乎优先,即使它也安装在/Library/Python/2.7/site-packages下!

on a .tar.gz distribution downloaded directly from sourceforge, the upgraded installation does not appear to take precedence in the Python module load path, even though it is also installed under /Library/Python/2.7/site-packages!

无论如何,要解决此问题(或更确切地说,至少在Max OS X上,我应该说要解决该错误),请按照以下步骤操作:

Anyway, to fix the problem (or rather, I should probably say, to work around the bug, at least on Max OS X), follow this procedure:

  1. 使用您选择的方法从/Library/Python/2.7/site-packages卸载numpy软件包(pip uninstall numpy似乎对我有用)
  2. 验证/Library/Python/2.7/site-packages
  3. 下确实不再有任何numpy软件包
  4. 使用出厂随附的/usr/bin/easy_install重新安装numpy.不要使用任何其他替代方法,至少不要将numpy与Apple出厂安装的Python 2.7版本一起使用
  1. Uninstall the numpy package from /Library/Python/2.7/site-packages using the method of your choice (pip uninstall numpy appeared to work for me)
  2. Verify that there is indeed no longer any numpy package still remaining under /Library/Python/2.7/site-packages
  3. Reinstall numpy using the factory-included /usr/bin/easy_install. Do not use any other alternative method, at least not if you want to use numpy with the Apple factory-installed version of Python 2.7

或者,使用已经完全提到过的其他评论者之一,使用完全不同的Python发行版(例如Canopy或Anaconda)也应该起作用.

Alternatively, using a completely different distribution of Python (e.g., Canopy or Anaconda), as one of the other commenters already mentioned, should also work as well.

这篇关于Python Numpy从1.6更新到1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆