[转载] python更新numpy_Python numpy从1.6更新到1.8

在Mac OS X 10.9上,用户遇到Python中numpy版本显示不一致的问题。尽管卸载并重新安装numpy,系统仍加载旧版本。原因是系统有两个numpy的安装位置。正确解决方案是使用系统自带的`/usr/bin/easy_install`重新安装numpy,或者考虑使用如Canopy或Anaconda等不同Python发行版。
摘要由CSDN通过智能技术生成

参考链接: Python中的numpy.fix

I have installed numpy 1.8. But when I do print numpy.__version__ it says 1.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.

 Edit:

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

 python

 import numpy

 print numpy.version

 and it printed out 1.6.2

 I can't delete numpy apparently.

 解决方案

 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

 it removes the version of numpy installed under

 /Library/Python/2.7/site-packages

 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

 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

 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!

 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:

 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)

 Verify that there is indeed no longer any numpy package still remaining under /Library/Python/2.7/site-packages

 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

 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值