为什么`pip install hwrt --upgrade`升级到随机版本(有时也会降级)?

时间:2015-02-02 16:52:52

标签: python pypi

我刚刚执行了

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

1 个答案:

答案 0 :(得分: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。