为什么pipinstall有时会选择不兼容的版本



在我的python包htrest中(https://pypi.org/project/htrest/)我有以下要求:

requirements = [
'htheatpump==1.2.1',
'Flask==1.1.1',
'flask-restx==0.1.1',
'Flask-BasicAuth==0.2.0',
# put package requirements here
]

当我使用pip install htrest安装它时,它有时会失败,并显示以下消息:

flask-restx 0.1.1 has requirement werkzeug<=0.16.1, but you'll have werkzeug 1.0.0 which is incompatible.

看起来pip选择werkzeug==1.0.0是因为Flask(Werkzeug>=0.15(的要求

Collecting Werkzeug>=0.15 (from Flask==1.1.1->htrest)
Using cached https://files.pythonhosted.org/packages/ba/a5/d6f8a6e71f15364d35678a4ec8a0186f980b3bd2545f40ad51dd26a87fb1/Werkzeug-1.0.0-py2.py3-none-any.whl

虽然CCD_ 5需要CCD_。

另一方面,有时pip会选择合适的werkzeug(0.16.1(版本:

Collecting werkzeug<=0.16.1 (from flask-restx==0.1.1->htrest)
Using cached https://files.pythonhosted.org/packages/c2/e4/a859d2fe516f466642fa5c6054fd9646271f9da26b0cac0d2f37fc858c8f/Werkzeug-0.16.1-py2.py3-none-any.whl

以满足CCD_ 9CCD_。

有人能解释一下原因以及如何解决这个问题吗?

谨致问候,丹尼尔。

默认情况下,pip install <package_name>命令始终查找软件包的最新版本并安装它。同时,它还搜索软件包元数据中列出的依赖项的最新版本并安装这些依赖项,以确保软件包具有所需的所有要求。

如果要安装以前的版本,则必须指定此版本。这篇文章提供了关于pip如何工作的全部细节

在你的情况下,你应该这样做:

pip3 uninstall Werkzeug        # uninstalling the current Werkzeug
pip3 install Werkzeug==0.16.1  # install specific version of Werkzeug

最新更新