我通过虚拟机安装了Ubuntu,并且预先安装了Python3。我想尝试使用Python2制作的软件包,所以我安装了Python 2.7(成为默认的Python)和Anaconda2。
现在我已经完成了该程序包,我删除了anaconda2,也想删除Python2,但是如果它是默认程序,恐怕它将破坏我的系统。如何安全地进行此操作?
(base) me@me-VirtualBox:~$ whereis python
python: /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python2.7-config /usr/bin/python /usr/bin/python2.7 /usr/lib/python3.7 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib/python2.7 /etc/python3.6 /etc/python /etc/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/include/python3.6m /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
(base) me@me-VirtualBox:~$ which python
/usr/bin/python
您可以使用:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
将其设置为默认值,而不删除python2.7
这将指向命令python
使用/usr/bin/python3.6
或者如果update-alternatives --list python
显示多个结果,则可以交互选择要使用的版本::
update-alternatives --config python