在我的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尽管flask-restx需要werkzeug<=0.16.1。
另一方面,有时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以适应Flask 和 flask-restx的要求。
有人能解释一下原因以及如何解决这个问题吗?
你好,丹尼尔。
发布于 2020-03-17 18:32:27
默认情况下,pip install <package_name>命令总是查找包的最新版本并安装它。同时,它还搜索包元数据中列出的依赖项的最新版本,并安装这些依赖项,以确保包具有它所需的所有需求。
如果要安装以前的版本,则必须指定此版本。本文详细介绍pip的工作原理。
在你的例子中,你应该这样做:
pip3 uninstall Werkzeug # uninstalling the current Werkzeug
pip3 install Werkzeug==0.16.1 # install specific version of Werkzeughttps://stackoverflow.com/questions/60728023
复制相似问题