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

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

这里发生了什么?

我有来自/usr/local/lib/python2.7/dist-packages (python 2.7) 的 pip 6.0.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...

最佳答案

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

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。

关于python - 为什么 `pip install hwrt --upgrade`会升级到随机版本(有时也会降级)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28282671/

相关文章:

python - 如何将 python datetime(ISO) 截断为小时?

python - 在 Pandas 中获取平均年份(多年平均天数)

Python 守护进程在一两个小时后退出

python - 如何理解 Python 循环的 `else` 子句?

conda - "pypi"输出的 "Channel"列中的 `conda list` 意味着什么?

python - --extra-index-url 在 python requirements.txt 中不起作用

python - 如何为 Python 列表切片返回任何内容

python - PyPI 包的安装统计数量?

python - 如何使用 python setup.py 上传?

python - 使用 twine : Invalid URI 将包上传到 pypi