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

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

问题描述

我刚刚将我的包的新版本上传到 PyPi (1.2.1.0-r4):我可以下载 egg 文件并使用 easy_install 安装它,并且版本检查正确.但是当我尝试使用 pip 安装时,它会安装 1.1.0.0 版.即使我使用 pip install -Iv tome==1.2.1.0-r4 明确指定要 pip 的版本,我也会收到此消息:Requested tome==1.2.1.0-r4,但正在安装版本 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:

那么知道为什么选择安装 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 会更喜欢本地版本而不是远程版本.我什至断开了我的计算机与互联网的连接并再次尝试 - 当 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,满足要求

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天全站免登陆