I've just uploaded a new version of my package to PyPi (1.2.1.0-r4): I can download the egg file and install it with easy_install, and the version checks out correctly. But when I try to install using pip, it installs version 1.1.0.0 instead. Even if I explicitly specify the version to pip with pip install -Iv tome==1.2.1.0-r4
, I get this message: Requested tome==1.2.1.0-r4, but installing version 1.1.0.0
, but I don't understand why.
I double checked with parse_version
and confirmed that the version string on 1.2.1 is greater than that on 1.1.0 as shown:
>>> from pkg_resources import parse_version as pv
>>> pv('1.1.0.0') < pv('1.2.1.0-r4')
True
>>>
So any idea why it's choosing to install 1.1.0 instead?
This is an excellent question. It took me forever to figure out. This is the solution that works for me:
Apparently, if pip
can find a local version of the package, pip
will prefer the local versions to remote ones. I even disconnected my computer from the internet and tried it again -- when pip
still installed the package successfully, and didn't even complain, the source was obviously local.
The really confusing part, in my case, was that pip
found the newer versions on pypi, reported them, and then went ahead and re-installed the older version anyway ... arggh. Also, it didn't tell me what it was doing, and why.
So how did I solve this problem?
You can get pip
to give verbose output using the -v
flag ... but one isn't enough. I RTFM-ed the help, which said you can do -v
multiple times, up to 3x, for more verbose output. So I did:
pip install -vvv <my_package>
Then I looked through the output. One line caught my eye:
Source in /tmp/pip-build-root/ has version 0.0.11, which satisfies requirement <my_package>
I deleted that directory, after which pip
installed the newest version from pypi.