Ubuntu
無法刪除 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.
我怎樣才能刪除它?
您需要刪除與以下內容一起安裝的軟體包
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
二進製文件的來源。
這裡任何嘗試或想要嘗試相同事情的人,不要在 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 並執行相同的命令。