19

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?

5
  • 1
    What does pip install -vv --no-install argparse say? Feb 19, 2014 at 3:06
  • 1
    argparse comes standard in Python2.7. While the pypy version number is 1.2.1, its last changed date was 2011. So it is not ahead of the latest Python release.
    – hpaulj
    Feb 19, 2014 at 4:00
  • 1
    @hpaulj my argparse.__version__ returns '1.1' in Python 2.7.6, not sure if this is the same version number though Feb 19, 2014 at 4:27
  • 2
    Don't worry about that 1.1. Since it is part of the standard library that number isn't changing anymore.
    – hpaulj
    Feb 19, 2014 at 4:57
  • @PeterGibson pip install -vv --no-install argparse says: DEPRECATION: '--no-install' and '--no-download are deprecated. See https://github.com/pypa/pip/issues/906. Requirement already satisfied (use --upgrade to upgrade): argparse in /usr/local/lib/python2.7/site-packages I've tested with a vagrant and even thought the version of argparse installed is 1.2.1, argparse.__version__ returns 1.1.
    – GabLeRoux
    Feb 19, 2014 at 6:34

3 Answers 3

10

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

1
  • I am using a recent version of pip:pip 1.5.2 from /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.2-py2.7.egg (python 2.7) Indeed, I always get that --allow-external message. I guess some developers will need to move their sources to pypi
    – GabLeRoux
    Feb 19, 2014 at 6:35
9

Here's the command I used to install argparse using pip 1.5.4:

pip install --allow-all-external argparse==1.2.1
1
  • So was the resulting argparse file any different from the standard one (2.7+)?
    – hpaulj
    May 2, 2014 at 16:57
0

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


This answer was posted as an edit to the question Pip doesn't install latest available version from pypi (argparse in this case) by the OP GabLeRoux under CC BY-SA 3.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.