点子为什么不更新我的Numpy和Scipy? [英] Why isn't pip updating my numpy and scipy?

查看:54
本文介绍了点子为什么不更新我的Numpy和Scipy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是即使没有错误,pip也不会更新我的Python软件包.

它类似于,但是我现在仍然确定该怎么做.基本上,即使通过pip更新了所有内容,我所有的python软件包似乎都已过时了.详细信息如下:

  • 我正在使用1.5.6版的pip.
  • 我正在使用Python,版本2.7.5
  • 我使用的是Mac OSX版本10.9.5.

使用它,我有:

  • 我的numpy版本是1.6.2.
  • 我的scipy版本是0.11.0.
  • 我的matplotlib版本是1.1.1.

即使在尝试之后:

sudo pip uninstall numpy

其次:

sudo pip install numpy

它们都成功完成,但是当我进入python并检查numpy的版本时,它仍然是旧版本. (其他所有软件包也是如此).

不知道这是怎么回事?...如何解决? P.S.我对此并不陌生,因此可能需要明确的说明.谢谢.另外,如果有人愿意,我可以在安装numpy时提供pip的屏幕截图.

我根据注释运行的命令:

$which -a pip
/usr/local/bin/pip
$ head -1 $(which pip)
#!/usr/bin/python
$ which -a python
/usr/bin/python

解决方案

在OS X 10.9中,Apple的Python在名为/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python的目录中附带了一堆预装的额外软件包.包括numpy.

以及它们的安装方式(就像将easy_install与早期的0.7以前版本的setuptools一起使用,但未插入任何普通的easy_install目的地中一样),pip不知道关于他们的任何事情.

因此,发生的情况是sudo pip install numpynumpy的单独副本安装到'/Library/Python/2.7/site-packages'中-但是在您的sys.path中,Extras目录位于site-packages目录之前,因此import numpy仍然找到苹果的副本.我不确定为什么会这样,但这可能不是您想要的东西.


那么,如何解决这个问题?

两个最佳解决方案是:

  • 使用 virtualenv ,然后将您的numpy和朋友安装到虚拟环境,而不是整个系统.这样做有一个缺点,那就是您必须学习如何使用virtualenv-但这绝对值得在某个时候做,如果您有时间现在学习它,那就去做吧.

  • 通过python.org安装程序或通过Homebrew升级到Python3.x. Python 3.4或更高版本附带pip,并且不附带任何pip-不友好的预安装软件包.而且,与安装单独的2.7不同,它完全不会干扰Apple的Python. python3pythonpip3pip等都是单独的程序,您无需了解PATH的工作原理或其他任何内容.这有一个缺点,那就是您必须学习Python 3.x,它具有一些重大更改,同样,这是一个学习曲线,但是再次,绝对值得在某个时候做.


假设这两种方法都不可行,我认为最简单的选择是使用easy_install而不是pip来安装要安装任何Apple"extras"的较新版本的软件包.通过查看/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python中的内容,可以获取这些内容的完整列表.升级numpy时,您可能还想升级scipymatplotlib.我认为其他所有内容都不相关. (当然,您可以升级PyObjCdateutil或您关心的其他任何内容,但不必这样做.)

这不是理想的解决方案. easy_install不如pip有很多原因(例如,没有卸载程序,因此您必须记住/Library/blah/blah路径在哪里(或通过打印出sys.path再次找到它)我通常不会建议easy_install用于readlinepip本身(然后仅适用于Apple的Python).但是在这种情况下,我认为它比其他选择要简单. >

My problem is that pip won't update my Python Packages, even though there are no errors.

It is similar to this one, but I am still now sure what to do. Basically, ALL my packages for python appear to be ridiculously outdated, even after updating everything via pip. Here are the details:

  • I am using pip, version 1.5.6.
  • I am using Python, version 2.7.5
  • I am on a Mac OSX, verion 10.9.5.

Using that, I have:

  • My numpy version is 1.6.2.
  • My scipy version is 0.11.0.
  • My matplotlib version is 1.1.1.

Even after I try:

sudo pip uninstall numpy

Followed by:

sudo pip install numpy

They both complete successfully, but when I go into python and check the version of numpy, it is still the old one. (As are all the other packages).

Not sure what is going on here?... How can this be fixed? P.S. I am new to this, so I might need explicit instructions. Thanks. Also, if anyone wants, I can provide a screenshot of pip as it is installing numpy.

EDIT:

Commands I ran as per the comments:

$which -a pip
/usr/local/bin/pip
$ head -1 $(which pip)
#!/usr/bin/python
$ which -a python
/usr/bin/python

解决方案

In OS X 10.9, Apple's Python comes with a bunch of pre-installed extra packages, in a directory named /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python. Including numpy.

And the way they're installed (as if by using easy_install with an ancient pre-0.7 version of setuptools, but not into either of the normal easy_install destinations), pip doesn't know anything about them.

So, what happens is that sudo pip install numpy installs a separate copy of numpy into '/Library/Python/2.7/site-packages'—but in your sys.path, the Extras directory comes before the site-packages directory, so import numpy still finds Apple's copy. I'm not sure why that is, but it's probably not something you want to monkey with.


So, how do you fix this?

The two best solutions are:

  • Use virtualenv, and install your numpy and friends into a virtual environment, instead of system-wide. This has the downside that you have to learn how to use virtualenv—but that's definitely worth doing at some point, and if you have the time to learn it now, go for it.

  • Upgrade to Python 3.x, either from a python.org installer or via Homebrew. Python 3.4 or later comes with pip, and doesn't come with any pip-unfriendly pre-installed packages. And, unlike installing a separate 2.7, it doesn't interfere with Apple's Python at all; python3 and python, pip3 and pip, etc., will all be separate programs, and you don't have to learn anything about how PATH works or any of that. This has the downside that you have to learn Python 3.x, which has some major changes, so again, a bit of a learning curve, but again, definitely worth doing at some point.


Assuming neither of those is possible, I think the simplest option is to use easy_install instead of pip, for the packages you want to install newer versions of any of Apple's "extras". You can get a full list of those by looking at what's in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python. When you upgrade numpy, you probably also want to upgrade scipy and matplotlib; I think everything else there is unrelated. (You can of course upgrade PyObjC or dateutil or anything else you care about there, but you don't have to.)

This isn't an ideal solution; there are a lot of reasons easy_install is inferior to pip (e.g., not having an uninstaller, so you're going to have to remember where that /Library/blah/blah path is (or find it again by printout out sys.path from inside Python). I wouldn't normally suggest easy_install for anything except readline and pip itself (and then only with Apple's Python). But in this case, I think it's simpler than the other alternatives.

这篇关于点子为什么不更新我的Numpy和Scipy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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