【问题标题】:Why does `pip install hwrt --upgrade` upgrade to a random version (sometimes also downgrade)?为什么 `pip install hwrt --upgrade` 会升级到随机版本(有时也会降级)?
【发布时间】:2015-04-01 16:33:50
【问题描述】:

我刚刚执行了

$ sudo pip install hwrt --upgrade

安装最新版本的 Python 包 hwrt。 我添加了使用hwrt --version 获取软件包版本的可能性。 现在我得到了这种奇怪的行为:

$ hwrt --version
hwrt 0.1.201
$ sudo pip install hwrt --upgrade
[... some output ...]
$ hwrt --version
hwrt 0.1.203
$ sudo pip install hwrt --upgrade
[... some output ...]
$ hwrt --version
hwrt 0.1.205
$ sudo pip install hwrt --upgrade
[... some output ...]
$ hwrt --version
hwrt 0.1.200

这里发生了什么?

我有pip 6.0.7 from /usr/local/lib/python2.7/dist-packages (python 2.7)

详细

我刚刚跑了sudo pip install hwrt --upgrade --verbose > install.log

完整日志在这里:http://pastebin.com/eZ9M9UVd

以下似乎很有趣:

[...]
Using version 0.1.211 (<-this is the version it should be)[...]
[...]
Collecting hwrt from https://pypi.python.org/packages/source/h/hwrt/hwrt-0.1.211.tar.gz#md5=b75ac2f4c644743cfa865f086163a93e
  "GET /packages/source/h/hwrt/hwrt-0.1.211.tar.gz HTTP/1.1" 200 2228910
  Downloading hwrt-0.1.211.tar.gz (2.2MB)
  Downloading from URL https://pypi.python.org/packages/source/h/hwrt/hwrt-0.1.211.tar.gz#md5=b75ac2f4c644743cfa865f086163a93e
  Running setup.py (path:/tmp/pip-build-lWJUXg/hwrt/setup.py) egg_info for package hwrt
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/hwrt.egg-info
    writing requirements to pip-egg-info/hwrt.egg-info/requires.txt
    writing pip-egg-info/hwrt.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/hwrt.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/hwrt.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/hwrt.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/hwrt.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    writing manifest file 'pip-egg-info/hwrt.egg-info/SOURCES.txt'
  Source in /tmp/pip-build-lWJUXg/hwrt has version 0.1.211, which satisfies requirement hwrt from https://pypi.python.org/packages/source/h/hwrt/hwrt-0.1.211.tar.gz#md5=b75ac2f4c644743cfa865f086163a93e
[...]
Found existing installation: hwrt 0.1.204
Uninstalling hwrt-0.1.204:
[...]
Successfully installed argparse-1.2.1 hwrt-0.1.209
Cleaning up...

【问题讨论】:

  • 也许,这就是为什么他们说,太多太糟糕了 ....
  • 也许添加 -v / --verbose 标志 - 它会更准确地向您展示它如何确定您拥有的版本以及它在哪里找到最新版本。此外,您省略的[... some output ...] 可能包含一些重要信息来解决这个问题。这听起来肯定是一个错误。您是否尝试过更新 pip 本身 (pip install --upgrade pip?)
  • @moose - 对我来说看起来像一个错误。它清楚地打印出 0.1.211 是最新版本,因此应该安装,但最后它说它安装了 0.1.209。我只浏览了其余部分,但没有看到任何需要使用旧版本 hwrt 的冲突。
  • 假设这是一个错误:现在是否正确报告并跟踪?
  • @Jan-PhilipGehrcke 我刚刚将它添加到错误跟踪器github.com/pypa/pip/issues/2408

标签: python pypi


【解决方案1】:

虽然我无法回答我认为是您的主要问题的为什么,但如果问题引起问题,我可以提供解决方案来解决问题。简短版本只是为了准确指定您想要的版本,例如:

trevor@nikola:~$ pip list --outdated | grep Django
Django (Current: 1.7.5 Latest: 1.7.6)
pip install -U Django==1.7.6

如果您正在创建某些内容并且想要指定保持静态的依赖项,那么这将特别有用,这样您就不必在底层依赖项发生更改时更新您的代码。

有时您不确定哪个版本合适,例如知道您需要使用“X 版之前”的版本,但不知道要安装的具体编号。如果您尝试安装不正确/不存在的版本,Pip 可以向您显示可用版本。例如:

trevor@nikola:~$ pip install Django==-1
Collecting Django==-1
  Could not find a version that satisfies the requirement Django==-1 
(from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 
... lots that I'm skipping ... 
1.6.8, 1.6.9, 1.6.10, 1.7, 1.7.1, 1.7.2, 1.7.3, 
1.7.4, 1.7.5, 1.7.6, 1.8a1, 1.8b1, 1.8b2)
  No distributions matching the version for Django==-1

所以我知道我需要安装 1.7 之前的版本,我可能可以使用 1.6.10。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-04
    • 2021-06-01
    • 2021-11-15
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多