为什么pip安装了旧版本的软件包? [英] Why is pip installing an old version of my package?

查看:208
本文介绍了为什么pip安装了旧版本的软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将软件包的新版本上传到PyPi(1.2.1.0-r4):我可以下载egg文件并使用easy_install进行安装,并且该版本可以正确检出.但是,当我尝试使用pip进行安装时,它将安装版本1.1.0.0.即使我用pip install -Iv tome==1.2.1.0-r4明确指定要点的版本,也会收到此消息:Requested tome==1.2.1.0-r4, but installing version 1.1.0.0,但我不明白为什么.

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.

我再次使用parse_version进行了检查,并确认1.2.1上的版本字符串大于1.1.0上的版本字符串,如下所示:

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

那么,为什么要选择安装1.1.0呢?

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:

显然,如果pip可以找到软件包的本地版本,则pip会首选本地版本而不是远程版本.我什至断开了计算机与Internet的连接,然后再次尝试了-当pip仍然成功安装了软件包,甚至没有抱怨时,该来源显然是本地的.

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.

在我看来,真正令人困惑的部分是pip pypi 上找到了较新的版本. ,报告了它们,然后继续并重新安装了旧版本... arggh.而且,它没有告诉我它在做什么,以及为什么.

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?

您可以使用-v标志获取pip给出详细的输出信息...但是一个还不够.我使用RTFM编辑帮助,它说您可以多次执行-v,最多3倍,以获得更详细的输出.所以我做到了:

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:

/tmp/pip-build-root/中的源版本为0.0.11,满足要求< my_package>

Source in /tmp/pip-build-root/ has version 0.0.11, which satisfies requirement <my_package>

我删除了该目录,然后pip从pypi安装了最新版本.

I deleted that directory, after which pip installed the newest version from pypi.

这篇关于为什么pip安装了旧版本的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆