Pip不会安装pypi的最新可用版本(在这种情况下为argparse) [英] Pip doesn't install latest available version from pypi (argparse in this case)

查看:277
本文介绍了Pip不会安装pypi的最新可用版本(在这种情况下为argparse)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我最近从事一些python项目,并且pip在未安装某些要求的最新版本时遇到很多问题.我在osx上,并且使用 brew 来安装Python 2.7.6.在我正在研究的项目中,我们只是pip install -r requirements.txt.在当前情况下,我需要安装argparse==1.2.1.这是pypi网站上显示的实际最新版本

这是我的输出

Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 4))
Could not find a version that satisfies the requirement argparse==1.2.1 (from -r requirements.txt (line 4)) (from versions: 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 1.0.1, 1.0, 1.1)
Some externally hosted files were ignored (use --allow-external to allow).
Cleaning up...
No distributions matching the version for argparse==1.2.1 (from -r requirements.txt (line 4))

我对不同的要求有类似的问题,例如matplotlib,我在在此处手动安装了该软件. /p>

如您所见,我的Mac上的pip仅具有那些argparse版本:0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 1.0.1, 1.0, 1.1

尝试修复

我尝试使用brew reinstall python重新安装python,然后还尝试使用一些xargs魔术方法重新安装所有已安装的python软件包:pip freeze | xargs -I {} sudo pip install {} --upgrade --force-reinstall.

在尝试重新安装所有内容时,我遇到了大多数软件包的问题:error: invalid command 'egg_info'.我发现我有一个旧的setuptools,所以我pip install --upgrade setuptools现在可以重新安装所有内容,但是argparse仍然存在相同的问题. argparse仍然是同样的问题.

我向一个刚安装了osx的朋友问到pip install argparse,他得到了1.1,所以我设置了precise32

我尝试在osx上使用--allow-external,但没有意识到它需要再次使用软件包的名称.

sudo pip install argparse --allow-external argparse --upgrade

和voilà:)

argparse an externally hosted file and may be unreliable
Downloading/unpacking argparse from http://argparse.googlecode.com/files/argparse-1.2.1.tar.gz#md5=2fbef8cb61e506c706957ab6e135840c
  Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded

正如彼得所指出的,最新版本的点子default to disallowing externally hosted files.

我认为这行是关键:

一些外部托管的文件被忽略(使用--allow-external允许).

当我在这里安装argparse时,我会得到

您正在安装外部托管的文件. pip的未来版本将默认不允许外部托管文件.

正在下载argparse-1.2.1.tar.gz(69kB):已下载69kB

因此您有一个更新版本的pip,默认情况下不允许外部托管文件

The problem

I worked on some python projects lately and had lots of problems with pip not installing the latest versions of some requirements. I am on osx and and I used brew to install Python 2.7.6. In the project I'm working on, we simply pip install -r requirements.txt. In the current case, I needed to install argparse==1.2.1. This is the actual latest version shown on the pypi website

Here's my output

Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 4))
Could not find a version that satisfies the requirement argparse==1.2.1 (from -r requirements.txt (line 4)) (from versions: 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 1.0.1, 1.0, 1.1)
Some externally hosted files were ignored (use --allow-external to allow).
Cleaning up...
No distributions matching the version for argparse==1.2.1 (from -r requirements.txt (line 4))

I had similar problems with different kinds of requirements such as matplotlib which I installed manually as seen here.

As you can see, pip on my mac only has those argparse versions: 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 1.0.1, 1.0, 1.1

Attempts to fix

I tried reinstalling python with brew reinstall python, then also tried to reinstall all of my installed python packages with some xargs magic: pip freeze | xargs -I {} sudo pip install {} --upgrade --force-reinstall.

While trying to reinstall everything, I had trouble with most of the packages: error: invalid command 'egg_info'. I figured out I had an old setuptools so I pip install --upgrade setuptools and I could now reinstall everything, but still, same problem with argparse. Still the same problem with argparse.

I asked a friend with a freshly installed osx to pip install argparse and he got 1.1 So I've setup a precise32 vagrant box for a clean ubuntu install with python-dev + libevent-dev and had no trouble at all installing argparse==1.2.1.

Temp fix

To continue working on the project, I installed argparse 1.1 on osx and it seems to work fine atm for what I'm working on.

Questions

I'm not very good with pypi (yet), but is-there any reason why I'm not getting the latest versions shown on pypi? Sounds like not all the libs on pypi are available for osx. Is there a way to know version availability for different os?

Edit: solution inside

argparse 1.1 seems to be the same as 1.2.1 as shown on this output

vagrant@precise32:~$ python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> argparse.__version__
'1.1'
>>> quit()
vagrant@precise32:~$ pip freeze | grep argparse
argparse==1.2.1

I tried to use --allow-external on osx, but did not realize it needed the name of the package again.

sudo pip install argparse --allow-external argparse --upgrade

and voilà :)

argparse an externally hosted file and may be unreliable
Downloading/unpacking argparse from http://argparse.googlecode.com/files/argparse-1.2.1.tar.gz#md5=2fbef8cb61e506c706957ab6e135840c
  Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded

As pointed out by Peter, latest version of pip default to disallowing externally hosted files.

解决方案

I think this line is the key:

Some externally hosted files were ignored (use --allow-external to allow).

When I install argparse here I get

You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files.

Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded

So you have a newer version of pip that is disallowing externally hosted files by default

这篇关于Pip不会安装pypi的最新可用版本(在这种情况下为argparse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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