【问题标题】:Hi, Unable to install python in Ubuntu 19.10 [duplicate]嗨,无法在 Ubuntu 19.10 中安装 python [重复]
【发布时间】:2021-05-08 15:15:46
【问题描述】:

在 ubuntu 19.10 中尝试下载 python 包时,出现此错误。试过 sudo apt-get update,但没用。如何在 ubuntu 服务器中安装 python

【问题讨论】:

  • 你是如何获得 ubuntu 19 的?我只看到了 16、18 和 20 个
  • Google 创造奇迹:askubuntu.com/questions/865554/…
  • Ubuntu 的非 LTS 版本(除了 {偶数}.04 之外的所有版本)的支持时间非常短。一年多后,您应该更新到 20.04 以获取软件和更新。
  • 为什么你要安装 Python 3.6,具体来说?这不是最新版本。此外,正如 Klaus 所说,您不应该在 Ubuntu 19.10 上运行。更新您的系统,然后安装最新的 Python(或您需要的任何版本)。
  • 我也尝试安装其他 python 版本,但是我有同样的问题。附上的截图供参考。由于我遇到了 PIP 包的问题,​​我已经删除了 PIP 和 python 以重新安装它

标签: python python-3.x ubuntu ubuntu-19.10


【解决方案1】:

Python 3.6+ 应该在 Ubuntu 18+ 上默认可用,因此首先找出包 repo 文件中列出的可用 Python 版本:

sudo apt search --names-only "^python3\."

查看结果并选择其中 1 个进行安装:

sudo apt install python3.6 # Or 3.7 3.8 3.9, etc

【讨论】:

  • 尝试了上述命令,但错误相同。
【解决方案2】:

安装python:

sudo apt-get install python3

但是 Ubuntu 已经自带了 python,所以你只需要使用python3。 请注意,在 Ubuntu 中,您始终必须指定版本 3。要执行文件,请运行:

python3 file.py

编辑:

要专门安装python 3.6,请执行:

sudo add-apt-repository ppa:fkrull/deadsnakes 
sudo apt-get update 
sudo apt-get install python3.6

【讨论】:

  • 这会一直安装 Python 3.6 吗?
  • 这将在存储库中安装最新版本的 python。如果你想处理不同版本的python,你应该使用anaconda或类似的东西来创建虚拟环境。
  • 我的意思是,OP 特别想要 Python 3.6,但这个答案目前建议安装最新版本,可能不是 3.6
  • 我已经更新了答案,你必须添加一个ppa
  • Error: sudo: add-apt-repository: command not found, 尝试使用 sudo apt-get install software-properties-common,得到以下错误:The following packages have unmet dependencies: Depends: python3但它不会被安装
猜你喜欢
  • 2020-07-04
  • 1970-01-01
  • 2020-11-01
  • 2019-11-25
  • 1970-01-01
  • 2021-11-28
  • 2015-05-05
  • 2018-11-10
  • 1970-01-01
相关资源
最近更新 更多