Why is pip installing an old version of my package

2019-01-10 14:05发布

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?

9条回答
Rolldiameter
2楼-- · 2019-01-10 14:37

Try forcing download the package again with:

pip install --no-cache-dir --upgrade <package>
查看更多
Explosion°爆炸
3楼-- · 2019-01-10 14:37

For my case I had to delete the .pip folder in my home directory and then I was able to get later versions of multiple libraries. Note that this was on linux.

pip --version
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
virtualenv --version
15.1.0
查看更多
做自己的国王
4楼-- · 2019-01-10 14:43

Thanks to Marcus Smith, who does amazing work as a maintener of pip, this was fixed in version 1.4 of pip which was released on 2013-07-23.

Relevant information from the changelog for this version

Fixed a number of issues (#413, #709, #634, #602, and #939) related to cleaning up and not reusing build directories. (Pull #865, #948)

查看更多
登录 后发表回答