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条回答
The star\"
2楼-- · 2019-01-10 14:22

I found here that there is a known bug in pip that it won't check the version if there's a build directory with unpacked sources. I have checked this on my troubling package and after deleting its sources from build directory pip installed the required version.

查看更多
你好瞎i
3楼-- · 2019-01-10 14:22

In my case the python version used (3.4) didn't satisfy Django 2.1 dependencies requirements (python >= 3.5).

查看更多
仙女界的扛把子
4楼-- · 2019-01-10 14:23

If you are using a pip version that comes with some distribution packages (ex. Ubuntu python-pip), you may need to install a newer pip version:

Update pip to latest version:

sudo pip install -U pip

In case of "virtualenv", skip "sudo":

pip install -U pip

Following command may be required, if your shell report something like -bash: /usr/bin/pip: No such file or directory after pip update:

hash -d pip

Now install your package as usual:

pip install -U foo

or

pip install foo==package.version.here

查看更多
成全新的幸福
5楼-- · 2019-01-10 14:25

I found that if you use microversions, pip doesn't seem to recognize them. For example, we couldn't get version 1.9.9.1 to upgrade.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-10 14:28

Got the same issue to update pika 0.9.5 to 0.9.8. The only working way was to install from tarball: pip install https://pypi.python.org/packages/source/p/pika/pika-0.9.8.tar.gz.

查看更多
爷的心禁止访问
7楼-- · 2019-01-10 14:36

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

查看更多
登录 后发表回答