无法删除 Python 3.6

无法删除 Python 3.6

我在 Azure 上设置了一个运行 Ubuntu 的虚拟机:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial

然后验证 Python 二进制文件和版本:

$ which python
/usr/bin/python
$ python --version
Python 2.7.12
$ which python3
/usr/bin/python3
$ python3 --version
Python 3.5.2

我安装了Python 3.6

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6

然后我删除了它

$ sudo apt-get remove python3.6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libpython3.6-minimal libpython3.6-stdlib python3.6-minimal
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python3.6
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 334 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 85368 files and directories currently installed.)
Removing python3.6 (3.6.8-1+xenial1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...

但它仍然安装:

$ python3 --version
Python 3.5.2
$ python3.6 --version
Python 3.6.8

现在我无法再删除它,因为apt-get它说尚未安装:

$ sudo apt-get remove python3.6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'python3.6' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libpython3.6-minimal libpython3.6-stdlib python3.6-minimal
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

我怎样才能删除它?

答案1

这里的任何其他人尝试过或想要尝试同样的事情,请不要在 Ubuntu 上以这种方式删除 Python3!它可能会删除您的整个 ubuntu 桌面。如果您遇到问题:

sudo apt-get install python3-all
sudo apt-get install gnome-terminal
sudo apt-get install ubuntu-desktop

如果您无法打开终端,请按Ctrl+ Alt+F1获取 shell 并运行相同的命令。

答案2

您需要删除与以下一起安装的软件包python3.6

sudo apt autoremove

apt-get这将删除告诉您删除时间的软件包python3.6

The following packages were automatically installed and are no longer required:
  libpython3.6-minimal libpython3.6-stdlib python3.6-minimal
Use 'sudo apt autoremove' to remove them.

包括二进制文件的python3.6-minimal来源python3.6

相关内容