gpt4 book ai didi

python - 为什么 pip 会卸载所需的包?

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:31 26 4
gpt4 key购买 nike

pip似乎大肆卸载需要的包!如果某个包显式声明了某个包的特定版本,则 pip 似乎应该无法卸载该包,但事实并非如此。考虑:

$ pip list | grep bar
bar 1.0
$ cat setup.py

from setuptools import setup, find_packages

def do_setup():
setup(
name='foo',
description='the foo package',
license='MIT',
version='1.0',
install_requires=[
'bar==1.0',
],
)

if __name__ == "__main__":
do_setup()
$ pip install .
Processing /Users/williamp/examples/pip/foo
Requirement already satisfied (use --upgrade to upgrade): foo==1.0 from file:///Users/williamp/examples/pip/foo in /Users/williamp/tmp/virt/lib/python2.7/site-packages
Requirement already satisfied: bar==1.0 in /Users/williamp/tmp/virt/lib/python2.7/site-packages (from foo==1.0)
$ cd ../bar
$ pip install dist/bar-1.1.tar.gz
Processing ./dist/bar-1.1.tar.gz
Building wheels for collected packages: bar
Running setup.py bdist_wheel for bar ... done
Stored in directory: /Users/williamp/Library/Caches/pip/wheels/bf/d3/68/6016190bb2084f62ba1107c63bea948f4cfbb2c129fa0cb102
Successfully built bar
Installing collected packages: bar
Found existing installation: bar 1.0
Uninstalling bar-1.0:
Successfully uninstalled bar-1.0
Successfully installed bar-1.1

似乎我最终遇到了这样的情况:安装了软件包 foo 并明确依赖于 bar == 1.0,但 pip 已卸载 bar 1.0 并且系统现在处于不稳定状态。是否有一些简单的配置选项可以传递给 pip 来告诉它不要这样做?

最佳答案

否,但您可以通过运行 pip check 手动检查:

$ pip check
No broken requirements found.
$ pip uninstall pytz
Uninstalling pytz-2017.3:
...
Proceed (y/n)? y
Successfully uninstalled pytz-2017.3
$ pip check
Django 2.0 requires pytz, which is not installed.

依赖关系跟踪已 a major issue现在用 pip 一段时间了。我希望它最终会得到修复。

关于python - 为什么 pip 会卸载所需的包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47784713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com