我已经尝试了正常的方法,sudo apt-get install python3.6但是……好吧……那没有用。
那么,我该怎么办呢?(我最好不要自己构建它)
我正在使用 Ubuntu 16.04。
使用 Ubuntu 17.04。根据https://askubuntu.com/a/865569/695385通过终端将 Python 3.5 更新到 3.6 后,仍然显示版本为 3.5.3。
~$ python3 --version
Python 3.5.3
Run Code Online (Sandbox Code Playgroud)
这是如何安装的?
我在运行 Ubuntu 20.04 的笔记本电脑上安装了以下版本的 Python:
python2
python3.10
python3.9
python3-pasteurize
python2.7
python3.8
python3-config
python-argcomplete-check-easy-install-script
python3
python3.8-config
python3-futurize
python-argcomplete-tcsh
Run Code Online (Sandbox Code Playgroud)
我知道 Ubuntu 依赖于其中的一些,我可以安全地删除哪些?
编辑:
正如评论中所要求的,这里是输出ls -l /usr/bin/python[23]* /usr/local/bin/python[23]*:
ls: cannot access '/usr/local/bin/python[23]*': No such file or directory
lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3674216 Mar 8 2021 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 Mar 12 2021 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5454136 Oct 5 00:09 /usr/bin/python3.10
-rwxr-xr-x 1 root root …Run Code Online (Sandbox Code Playgroud) 我已将 python 升级到 3.7 版,现在我的终端没有打开。
我关注了这篇文章https://jcutrer.com/linux/upgrade-python37-ubuntu1810
我运行的命令如下,
sudo apt-get install python3.7
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
sudo update-alternatives --config python3
Run Code Online (Sandbox Code Playgroud)
为python3.7输入2
我无法打开终端并运行命令。
我的 ubuntu 版本是 Ubuntu 18.04.2 LTS
我很好奇 Ubuntu 是否会为其每个版本“固定”较小的 Python 版本。查看Focal 中的软件包详细信息python3,与其他 LTS 版本相比,例如Bionic似乎坚持使用 Python 3.6。这在任何地方都有记载吗?或者这只是目前的现状?或者我误解了 Ubuntu 软件包?
我确实找到了一个相关的问题,但不完全相同,所以它没有回答我的问题:Pin Python Minor version in Ubuntu 18.04.4 LTS
我尝试从这里安装 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)