簡體   English   中英

ubuntu壞了 python 安裝錯誤

[英]ubuntu broken python installation by mistake

我試圖更新 Python 並且我不知道版本的隔離而是刪除版本,所以,我已經刪除了 Z3D945423F8E9494BPS4629A5D16C 中的所有 Python 版本。 現在我無法通過 apt-get 安裝任何東西。

root@vps15:/# apt-get install --reinstall python3.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我嘗試手動安裝以將 Python 2.7 安裝到 /usr/lib 並且現在可以使用,但現在的問題是這種依賴關系:“dh-python”。

# apt-get install python3.5-minimal
Reading package lists... Done
Building dependency tree      
Reading state information... Done
python3.5-minimal is already the newest version (3.5.2-2ubuntu0~16.04.5).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python3.5-minimal : Depends: libpython3.5-minimal (= 3.5.2-2ubuntu0~16.04.5) but it is not installable
                     Recommends: python3.5 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我已經嘗試了所有列出的方法,但無法修復依賴關系。

在嘗試修復之前,問題是 Python2.7 而不是 python3,現在手動安裝 python3 並沒有解決問題。

經過更多研究,我創建了一個與 Debian 相關的帖子。 處理 Ubuntu 16.04 的一些修改,嘗試了本指南,現在一切正常:

步驟1。

cd /tmp
apt-get download libpython3.5-minimal
apt-get download python3.5-minimal
apt-get download python3-minimal
apt-get download libpython3.5-stdlib
apt-get download python3.5

第2步。

rm -rf /usr/local/lib/python3.5*
rm -rf /usr/local/bin/python3.5*
update-alternatives --remove python3 /usr/local/bin/python3.5
hash -r  # removes cached python3 binary path

步驟 3。

cd /tmp
dpkg-deb -x libpython3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x libpython3.5-stdlib_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3-minimal_3.5.1-3_amd64.deb missing

第4步。

cd /tmp/missing
ls -lR /tmp/missing  # if you are curious about overwriting your HD
sudo cp -rpfv /tmp/missing/*  /

步驟 5。

python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

導入並測試新版本:

>>> import sys
>>> print(sys.version_info)
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
>>>
>>> quit()

步驟 6。

rm -rf /tmp/missing

步驟 7。

dpkg -s -a python3.5 | grep  reinstreq
# Any listing also needs to be reinstalled along with python3
apt-get install --reinstall python3

步驟 8。

apt-get autoclean
apt-get autoremove
# (see the packages that will autoremove, you need to reinstall it again after: apt-get install --fix-broken --reinstall <<packages>>)

步驟 9。

嘗試安裝通用道具。

sudo apt install software-properties-common

如果它工作,現在安裝完成。


我已經為 Ubuntu 16.04 嘗試了這個,安裝了 Python2.7,但沒有安裝 Python3 或 Python3.5。 我最初安裝的是 Python3.5,這就是為什么嘗試安裝該版本而不是最新版本的原因。

感謝您指出根本原因。 For me the issue was broken distro_info package installed by pip and pip itself was so broken that I could not uninstall the package via pip uninstall . 我刪除了/usr/local/lib/python3.8所以do-release-upgrade將使用/usr/lib/python3.8下的原始 Ubuntu 包。 這解決了這個問題。 我從 20.04 => 22.04 開始更新。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM