![我想从 16.04 升级到 Ubuntu 18.04。“软件更新程序”和“sudo do-release-upgrade”都不起作用](https://linux22.com/image/1579227/%E6%88%91%E6%83%B3%E4%BB%8E%2016.04%20%E5%8D%87%E7%BA%A7%E5%88%B0%20Ubuntu%2018.04%E3%80%82%E2%80%9C%E8%BD%AF%E4%BB%B6%E6%9B%B4%E6%96%B0%E7%A8%8B%E5%BA%8F%E2%80%9D%E5%92%8C%E2%80%9Csudo%20do-release-upgrade%E2%80%9D%E9%83%BD%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
当我尝试时sudo do-release-upgrade
我得到:
Traceback (most recent call last):
File "/usr/bin/do-release-upgrade", line 11, in <module>
from UpdateManager.Core.MetaRelease import MetaReleaseCore
File "/usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py", line 25, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/do-release-upgrade", line 11, in <module>
from UpdateManager.Core.MetaRelease import MetaReleaseCore
File "/usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py", line 25, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
到目前为止我已经尝试过:
sudo apt update
sudo apt upgrade
sudo dist-upgrade
sudo apt autoremove
sudo do-release-upgrade
sudo update-manager
apt-get install -f
sudo apt install update-manager
sudo apt install ubuntu-release-upgrader-core
apt-get install python-apt
sudo apt remove python3-apt
sudo apt install python3-apt
sudo apt-get install python3-apt --reinstall
sudo rm -rf /var/lib/apt/lists/*
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-34m-i386-linux-gnu.so apt_pkg.so
sudo ln -s apt_pkg.cpython-{35m,34m}-x86_64-linux-gnu.so
sudo ln -s apt_pkg.cpython-{35m,34m}-x86_64-linux-gnu.so apt_pkg.so
/usr/bin/update-manager
sudo apt clean
当我尝试时:
sudo mv /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.bak
我有:
mv: cannot stat '/usr/share/dbus-1/system-services/org.freedesktop.systemd1.service': No such file or director
是
当然,做完这些之后,我再次尝试:
sudo apt update
sudo apt upgrade
sudo dist-upgrade
sudo apt autoremove
sudo do-release-upgrade
仍然不起作用。
答案1
这有点晚了,但我希望这能帮助目前遇到此问题的人。
对我来说,通过运行命令可以解决这个问题:
sudo apt install --reinstall python3 python python3-minimal --fix-broken
答案2
如果你尝试过FOSS 的分步指导并且失败了,那么替代方案是下载Ubuntu 18.04 ISO并进行全新安装。这样做的好处是可以删除旧的 Unity 包和设置,因为 18.04 使用 GNOME。
当然,这会丢失所有自定义设置和数据,因此请保存数据并制作磁盘映像,以防出现问题。我完成了 16.04 的升级和全新安装,我发现第二种选择更快、更简单,尽管缺点是需要重新安装数据和额外的软件包。
答案3
对我有用的是检查/var/log/dist-upgrade/main.log
它有 2 个问题 /usr/bin/python 需要指向 python2.7 和 /usr/bin/python3 需要指向 python3.5。
答案4
我有同样的问题...
sudo apt install --reinstall python3 python python3-minimal --fix-broken
对我有用