我想通过docutils
安装最新版本的pip
,但它不知道如何升级通过apt
安装的系统版本。
$ sudo --set-home python2 -m pip install --upgrade docutils
Collecting docutils
Using cached https://files.pythonhosted.org/packages/3a/dc/bf2b15d1fa15a6f7a9e77a61b74ecbbae7258558fcda8ffc9a6638a6b327/docutils-0.15.2-py2-none-any.whl
Installing collected packages: docutils
Found existing installation: docutils 0.14
ERROR: Cannot uninstall 'docutils'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
$ apt-cache show python-docutils | head -n 3
Package: python-docutils
Architecture: all
Version: 0.14+dfsg-3
我在网上想到或找到的解决方案都没有吸引力:
用
apt
删除rm -rf /usr/lib/python2.7/dist-packages/docutils*
版本。这种沉默pip
但意味着:系统上安装的文件不再符合Debian打包系统的想法
我可能会打破系统软件对docutils 0.14的依赖
对debian包的任何更新都将导致重新安装
this answer中讨论的其他问题
apt
。(同样的问题。)pip install --force-reinstall
。(同样的问题。)有没有办法获得一个默认的环境,它可以在
pip install --ignore-install
中使用最新版本的东西,但不可能破坏任何系统软件?The same answer above建议使用pip
,virtualenv
,venv
,pyenv
中的一个。我尝试了pipenv
,但它不想使用pipenv
安装命令行中列出的单个软件包,我不知道创建--system
是否真的能解决这个问题。我不想以某种方式手动切换环境来使用安装了
Pipfile
的软件包和安装了apt
的软件包。有没有办法让安装了pip
的软件只使用一个环境,或者使用安装了apt
的软件的环境? 最佳答案
我宁愿不用手动切换环境来使用apt安装的包而不是pip安装的包。有没有办法只让apt安装的软件使用一个环境,或者使用pip安装的环境?
理想情况下,应该使用系统版本或pip版本。
根据Debian Python Policy,
只要不在路径中安装其他版本的python,debian的python版本就不会受到新版本的影响。
如果安装的是已安装的python版本的其他微版本,则还需要小心安装该版本python使用的所有模块。
关于python - 使用pip升级最初通过apt安装的软件包,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57380039/