title: Pip doesn't install latest available version from pypi (argparse in this case)
body: <h2>The problem</h2>
  <p>I worked on some python projects lately and had lots of problems with <code>pip</code> not installing the latest versions of some requirements. I am on <code>osx</code> and and I used <a href="http://brew.sh/" rel="nofollow noreferrer">brew</a> to install <code>Python 2.7.6</code>. In the project I'm working on, we simply install requirements like this:</p>
  <pre class="lang-bash prettyprint-override"><code>pip install -r requirements.txt
  </code></pre>
  <p>In the current case, I needed to install <code>argparse==1.2.1</code>. This is the actual latest version shown <a href="https://pypi.python.org/pypi/argparse" rel="nofollow noreferrer">on the pypi website</a></p>
  <p>Here's my output</p>
  <pre class="lang-text prettyprint-override"><code>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))
  </code></pre>
  <p>I had similar problems with different kinds of requirements such as <code>matplotlib</code> which I installed manually as seen <a href="https://stackoverflow.com/a/4781684/1092815">here</a>.</p>
  <p>As you can see, pip on my mac only has those argparse versions: <code>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</code></p>
  <h2>Attempts to fix</h2>
  <p>I tried reinstalling python with <code>brew reinstall python</code>, then also tried to reinstall all of my installed python packages with some <code>xargs</code> <em>magic</em>:</p>
  <pre class="lang-bash prettyprint-override"><code>pip freeze | xargs -I {} pip install {} --upgrade --force-reinstall
  </code></pre>
  <p>While trying to reinstall everything, I had trouble with most of the packages: <code>error: invalid command 'egg_info'</code>. I figured out I had an old <code>setuptools</code> so I ran this to upgrade:</p>
  <pre class="lang-bash prettyprint-override"><code>pip install --upgrade setuptools
  </code></pre>
  <p>and I could now reinstall everything, but still, same problem with <code>argparse</code>.</p>
  <p>I asked a friend with a freshly installed osx to <code>pip install argparse</code> and he got <code>1.1</code> So I've setup a <code>precise32</code> <a href="http://www.vagrantup.com/" rel="nofollow noreferrer">vagrant box</a> for a clean ubuntu install with <code>python-dev</code> + <code>libevent-dev</code> and had no trouble at all installing <code>argparse==1.2.1</code>.</p>
  <h2>Workaround</h2>
  <p>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.</p>
  <h2>Questions</h2>
  <ol>
  <li><p>Is-there any reason why I'm not getting the latest versions shown on pypi?<br />
  Sounds like not all the libs on pypi are available for osx.</p>
  </li>
  <li><p>Is there a way to know version availability for different os?</p>
  </li>
  </ol>
  <h2>Edit: solution inside</h2>
  <p>argparse <code>1.1</code> seems to be the same as <code>1.2.1</code> as shown on this output</p>
  <pre class="lang-python prettyprint-override"><code>vagrant@precise32:~$ python
  Python 2.7.3 (default, Sep 26 2013, 20:08:41)
  [GCC 4.6.3] on linux2
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import argparse
  &gt;&gt;&gt; argparse.__version__
  '1.1'
  &gt;&gt;&gt; quit()
  vagrant@precise32:~$ pip freeze | grep argparse
  argparse==1.2.1
  </code></pre>
  <p>I tried to use <code>--allow-external</code> on osx and the requirement needs to be placed <strong>after</strong> <code>--allow-external</code> flag, not before. Here's a valid command to install <code>argparse</code> and allowing externally hosted files with <code>pip</code> for Python2.7:</p>
  <pre class="lang-bash prettyprint-override"><code>pip install --allow-external argparse --upgrade
  </code></pre>
  <pre class="lang-text prettyprint-override"><code>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
  </code></pre>
  <p>As pointed out by Peter, latest version of pip <code>default to disallowing externally hosted files</code>. </p>