Nor*_*ude 8 upgrade package-management apt python3 22.04
我尝试从这里安装 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 status 1
Setting up idle-python3.12 (3.12.1-1+jammy1) ...
Setting up python3.12-venv (3.12.1-1+jammy1) ...
dpkg: dependency problems prevent configuration of python3.12-full:
python3.12-full depends on libpython3.12-testsuite; however:
Package libpython3.12-testsuite is not configured yet.
dpkg: error processing package python3.12-full (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup erro
r from a previous failure.
Setting up python3.12-gdbm:amd64 (3.12.1-1+jammy1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
libpython3.12-testsuite
python3.12-full
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
当我重新启动它时,终端根本不会打开。我必须使用++Ctrl来获取tty并更改python3版本。
现在,我已经完全删除了 python3.12,正在等待回复。AltF3
小智 12
切勿删除或替换 Ubuntu Linux 中安装的官方 Python 版本!您所关注的文章的作者犯了一个错误,您可以在安装 Python 3.12 后删除不需要的 Python 版本。你永远无法删除官方的。对于 Ubuntu 22.04 来说是 3.10。
在你的情况下,我不相信你已经删除了官方的Python 3.10。您刚刚将其从程序中python或python3替代方案中删除update-alternatives。您只需运行一组命令即可将 APT 恢复到工作状态,例如:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10或者类似的。我希望您能获得 3.10 Python 版本的文档update-alternatives并在替代方案列表中找到恢复 3.10 Python 版本的方法。
您仍然可以安装几个版本以及官方版本,并将它们全部添加到替代版本中。这将允许您的 IDE 和其他软件查看并选择要使用的版本。
未完全安装 Python 3.12 的问题是由于源存储库 - deadsnakes的作者错误地更新了 Python 包 (3.12.1) 。他们需要用决议重建它,以便核心策略使其无法安装(SyntaxError: from __future__ imports must occur at the beginning of the file)。除了以下两种之外,我没有看到任何其他方法:
例如,可以在GitHub 上的主要问题跟踪器上提出此问题。他们修复软件包后,您将能够运行sudo apt update && sudo apt upgrade以获得完全更新的最新 Python 3.12.1。
| 归档时间: |
|
| 查看次数: |
6769 次 |
| 最近记录: |