Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip doesn't install latest available version from pypi (argparse in this case)

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 install requirements like this:

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 {} 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 ran this to upgrade:

pip install --upgrade setuptools

and I could now reinstall everything, but still, 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.

Workaround

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

Questions

  1. 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.

  2. 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 and the requirement needs to be placed after --allow-external flag, not before. Here's a valid command to install argparse and allowing externally hosted files with pip for Python2.7:

pip install --allow-external argparse --upgrade
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. 🙌

like image 634
GabLeRoux Avatar asked Feb 19 '14 00:02

GabLeRoux


1 Answers

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

like image 59
Peter Gibson Avatar answered Sep 28 '22 09:09

Peter Gibson