[英]Unable to downgrade version of Python package by `pip install -I`
To temporary workaround a compatibility issue, I tried to downgrade version of Python package arrow
from 0.17.0 to 0.13.2.为了临时解决兼容性问题,我尝试将 Python package arrow
的版本从 0.17.0 降级到 0.13.2。
On a particular server I was unable to, as the below command calls to install 0.13.2 but ends up install back 0.17.0.在特定服务器上我无法安装,因为以下命令调用安装 0.13.2 但最终安装回 0.17.0。 If remove the virtual environment, and generate a new one and freshly install 0.13.2, it works OK.如果删除虚拟环境,并生成一个新环境并全新安装 0.13.2,则可以正常工作。
I also tested on a virtual machine, and the downgrade works OK without this symptom.我也在虚拟机上进行了测试,降级工作正常,没有这个症状。
I'm wondering why, and any inputs will be highly appreciated.我想知道为什么,任何投入都将受到高度赞赏。
(venv3.7) [user@host freeze]$ pip install -I arrow==0.13.2
Collecting arrow==0.13.2
Using cached arrow-0.13.2-py2.py3-none-any.whl (37 kB)
Collecting python-dateutil
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting six>=1.5
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, python-dateutil, arrow
Successfully installed arrow-0.17.0 python-dateutil-2.8.1 six-1.15.0
(venv3.7) [user@host freeze]$
Use --force-reinstall
instead of -I, --ignore-installed
.使用--force-reinstall
而不是-I, --ignore-installed
。
-I
can break existing installs, according to the docs: - 根据文档, -I
可以破坏现有的安装:
-I, --ignore-installed
Ignore the installed packages, overwriting them.-I, --ignore-installed
忽略已安装的包,覆盖它们。 This can break your system if the existing package is of a different version or was installed with a different package manager!如果现有的 package 是不同的版本或安装了不同的 package 管理器,这可能会破坏您的系统!
If you want to install a version older than what you currently have installed, --force-reinsall
is a better fit:如果您想安装比您当前安装的版本更旧的版本, --force-reinsall
更适合:
--force-reinstall
Reinstall all packages even if they are already up-to-date.--force-reinstall
重新安装所有软件包,即使它们已经是最新的。
A demonstration of --force-reinstall
in action: --force-reinstall
的演示:
$ pip install arrow==0.17.0
Collecting arrow==0.17.0
<... snip ...>
Successfully installed arrow-0.17.0
$ pip install --force-reinstall arrow==0.13.2
Collecting arrow==0.13.2
<... snip ...>
Attempting uninstall: arrow
Found existing installation: arrow 0.17.0
Uninstalling arrow-0.17.0:
Successfully uninstalled arrow-0.17.0
Successfully installed arrow-0.13.2 python-dateutil-2.8.1 six-1.15.0
$ pip freeze | grep arrow
arrow==0.13.2
Another option from luasoftware.com luasoftware.com的另一个选项
% pip install arrow
Collecting arrow
Downloading arrow-1.2.1-py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 110 kB/s
Installing collected packages: six, python-dateutil, arrow
Successfully installed arrow-1.2.1
% pip install --upgrade arrow==0.13.2
Collecting arrow==0.13.2
Downloading arrow-0.13.2-py2.py3-none-any.whl (37 kB)
Installing collected packages: arrow
Attempting uninstall: arrow
Found existing installation: arrow 1.2.1
Uninstalling arrow-1.2.1:
Successfully uninstalled arrow-1.2.1
Successfully installed arrow-0.13.2
% pip list | grep arrow
arrow 0.13.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.