如何在linux ubuntu终端上安装python3.9?

2024-06-10 12:25:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试安装Python3.9 它回答说

Building dependency tree
Reading state information... Done
E: Unable to locate package python3.9
E: Couldn't find any package by glob 'python3.9'
E: Couldn't find any package by regex 'python3.9'

Tags: totreepackagebyinformationanyfinddependency
2条回答

如果您使用的是Ubuntu19.04 eoan(或deadsnakes ppa不支持的任何其他版本),您将无法使用deadsnakes ppa进行安装

相反,您可以做的是从Python的official website获取source,然后手动安装它,如here所述

为此,首先下载tarball并将其解压缩:

wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar -xf Python-3.9.0.tar.xz

然后将cd复制到提取的目录:

cd Python-3.9.0

现在配置脚本:

./configure

现在,要在当前Python安装(如果有)的同时安装Python 3.9,请使用:

sudo make altinstall

最后,您可以使用

python3.9  version

您遇到该错误是因为您首先需要更新包列表和先决条件

sudo apt update
sudo apt install software-properties-common

然后,将repo-ppa:deadsnakes/ppa添加到源代码列表中(您将从中下载python)

sudo add-apt-repository ppa:deadsnakes/ppa

出现提示时,请确保按enter键

最后,安装您选择的版本

sudo apt install python3.9

请务必阅读以下内容:

Disclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.

PPA Deadsnake

相关问题 更多 >