ubuntu安装最新版本的Python3.10
本教程需在root下执行。
$python3--versionPython3.8.10
aptupdateaptinstallsoftware-properties-common
- 添加deadsnakesPPA到源列表
安装过程中需要按Enter进入下一步
add-apt-repositoryppa:deadsnakes/ppaaptupdate
aptlist|greppython3.10

查看软件包是否包含python3.10
aptinstallpython3.10
$python3--versionPython3.8.10
update- alternatives--install/usr/bin/python3python3/usr/bin/python3.81update- alternatives--install/usr/bin/python3python3/usr/bin/python3.102

设置默认版本为Python3.10
update- alternatives--configpython3
$python--versionPython3.10.0
- 请勿移除旧版本的Python3.8,否则可能会导致一系列的问题。
- 修复pip和disutils
执行pip--version会报错:
ModuleNotFoundError:Nomodulenamed'distutils.util'

执行pip--version会报错
解决:
aptinstallpython3.10-distutils
aptupdateaptinstallsoftware-properties-common1

重装pip