【发布时间】:2020-05-16 04:33:04
【问题描述】:
我需要升级 Python 以安装需要版本>3.5.4 的包 (PyMC3)。我安装了 python 3.8.3 没有任何问题(安装必备库,使用 wget 从官方 repo 获取文件,使用 make altinstall 等),但是当我检查 python 版本时:
eric@debian:/$ python3 --version
Python 3.6.9 :: Anaconda, Inc.
eric@debian:~$ python3.8 --version
Python 3.8.3
(老实说,我不记得在这台计算机上安装过 anaconda!;根据 pymc3 安装错误,我的版本是 3.5.4)。我尝试使用更新替代方案来修复它:
eric@debian:~$ update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.8 10 auto mode
1 /home/eric/anaconda2/bin/python3 2 manual mode
2 /usr/local/bin/python3.8 10 manual mode
但是 python3 --version 继续抛出 Python 3.6.9 :: Anaconda, Inc. 当我尝试使用 pip 时:
eric@debian:~$ sudo pip3 pymc3
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/local/lib/python3.8/site-packages/pip/__init__.py)
阅读相关问题后,我尝试重新安装 python3-pip 但它已经是最新版本。我试图用sudo python3 -m pip uninstall pip 卸载它,但它给了我一堆红色的错误行,sudo -H pip3 install --upgrade pip 也不起作用(名称'main' 的 ImportError 相同)。顺便说一句:
eric@debian:~$ which pip3 pip
/usr/bin/pip3
/home/eric/anaconda2/bin/pip
eric@debian:~$ pip --version
pip 19.3.1 from /home/eric/anaconda2/lib/python3.6/site-packages/pip (python 3.6)
eric@debian:~$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/local/lib/python3.8/site-packages/pip/__init__.py)
提前致谢!
编辑:在多次尝试与此 ImportError 和 PATH 环境相关的帖子后,我删除了 Anaconda2(已损坏)并安装了 Anaconda3。它工作正常,但是当我尝试pip3 --version:
bash: /usr/bin/pip3: /usr/bin/python3: bad interpreter: No such file or directory
(但它确实存在)。当我尝试删除 pip3 时,例如,sudo apt remove python3-pip:
/bin/sh: 1: /usr/bin/apt-listchanges: not found
E: Sub-process /usr/bin/apt-listchanges --apt || test $? -lt 10 returned an error code (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
所以我对apt 有疑问,尽管阅读和尝试了很多小时,但我找不到删除、升级甚至重新安装 apt 的方法。
无论如何,我猜这个问题不再适合stackoverflow。我会尝试超级用户或类似的。
【问题讨论】:
-
请
apt install python3-pip -
完成,但失败:
"Reading package lists... Done Building dependency tree Reading state information... Done python3-pip is already the newest version (9.0.1-2+deb9u1). 0 upgraded, 0 newly installed, 0 to remove and 101 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y /bin/sh: 1: /usr/bin/apt-listchanges: not found E: Sub-process /usr/bin/apt-listchanges --apt || test $? -lt 10 returned an error code (1) E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
标签: python-3.x pip debian pymc3