我尝试从这里安装 python3.12 。然后我想将默认的python3(3.10)切换到新安装的并删除旧的(3.10),但事实证明,我无法像我想象的那样轻松摆脱旧版本。无论我做什么,都会带走所有系统文件。我曾经像这样搞乱过我的 Ubuntu 16.04,我不想再这样做了。
继续,在我使用update-alternatives命令更改 python3 以运行 python3.12 后,apt 停止工作并发生了很多错误。
当我更改 python3 版本时,除了以下错误之外还发生了此错误:
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 29, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Run Code Online (Sandbox Code Playgroud)
每当我运行 apt 时都会出现此错误:
Setting up libpython3.12-testsuite (3.12.1-1+jammy1) ...
File "/usr/lib/python3.12/test/test_future_stmt/badsyntax_future10.py", line 3
from __future__ import print_function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from __future__ imports must occur at the beginning of the file
dpkg: error processing package libpython3.12-testsuite (--configure):
installed libpython3.12-testsuite package post-installation script subprocess r
eturned error exit …Run Code Online (Sandbox Code Playgroud)