【问题标题】:Error on installing Python 3.9 on Ubuntu 20.04 > SOLVED [closed]在 Ubuntu 20.04 上安装 Python 3.9 时出错 > 已解决 [关闭]
【发布时间】:2021-02-20 13:39:06
【问题描述】:

我想在我的 Ubuntu 20.04 上安装 Python 3.9。

所以,我尝试按照以下步骤操作: https://phoenixnap.com/kb/how-to-install-python-3-ubuntu

但是,我有以下错误:

jordiba90@lts:~/Descargas/Python-3.9.0$ ./configure ––enable–optimizations
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: ––enable–optimizations
checking build system type... Invalid configuration `––enable–optimizations': machine
`––enable–optimizations' not recognized
configure: error: /bin/bash ./config.sub ––enable–optimizations failed

无论我尝试什么,我都有很多其他错误。可能是我操作系统的配置问题。

我希望这个问题不会违反 Stack 规则,但我真的不知道如何处理这个问题。

PS:Python 3.9 上的文件如下:

  • aclocal.m4
  • config.sub
  • 语法
  • 许可证
  • 杂项
  • 解析器
  • pyconfig.h.in
  • 工具 CODE_OF_CONDUCT.md
  • 配置
  • 包括
  • 平方米
  • 模块
  • 电脑
  • Python
  • config.guess
  • configure.ac
  • 安装-sh
  • 苹果机
  • netlify.toml
  • PC 构建
  • README.rstconfig.log
  • 文档
  • Makefile.pre.in
  • 对象
  • 程序
  • setup.py

PS_2:我有 Python 3.8,我想安装 3.9,但我遇到了很多错误。从源代码安装是我上次做的,很简单。

我试过了,还是不行。

PS_3:我尝试使用 hhe 包管理器安装,结果相同,请让我放弃更多声誉,但帮助新手了解我做错了什么

jordiba90@lts:~/Descargas/Python-3.9.0$ python3 --version
Python 3.8.5
jordiba90@lts:~/Descargas/Python-3.9.0$ sudo apt-get install software-properties-common
[sudo] contraseña para jordiba90: 
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
software-properties-common ya está en su versión más reciente (0.98.9.2).
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
jordiba90@lts:~/Descargas/Python-3.9.0$ sudo add-apt-repository ppa:deadsnakes/ppa
 This PPA contains more recent Python versions packaged for Ubuntu.

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.

Update Note
===========
Please use this repository instead of ppa:fkrull/deadsnakes.

Reporting Issues
================

Issues can be reported in the master issue tracker at:
https://github.com/deadsnakes/issues/issues

Supported Ubuntu and Python Versions
====================================

- Ubuntu 16.04 (xenial) Python 2.3 - Python 2.6, Python 3.1 - Python3.4, Python 3.6 - Python3.9
- Ubuntu 18.04 (bionic) Python2.3 - Python 2.6, Python 3.1 - Python 3.5, Python3.7 - Python3.9
- Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9
- Note: Python2.7 (all), Python 3.5 (xenial), Python 3.6 (bionic), Python 3.8 (focal) are not provided by deadsnakes as upstream ubuntu provides those packages.
- Note: for focal, older python versions require libssl1.0.x so they are not currently built

The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.

Packages
========

The packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu.  As such, the packages follow debian's patterns and often do not include a full python distribution with just `apt install python#.#`.  Here is a list of packages that may be useful along with the default install:

- `python#.#-dev`: includes development headers for building C extensions
- `python#.#-venv`: provides the standard library `venv` module
- `python#.#-distutils`: provides the standard library `distutils` module
- `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module
- `python#.#-gdbm`: provides the standard library `dbm.gnu` module
- `python#.#-tk`: provides the standard library `tkinter` module

Third-Party Python Modules
==========================

Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.

To install 3rd-party Python modules, you should use the common Python packaging tools.  For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:
https://packaging.python.org/installing/

Sources
=======
The package sources are available at:
https://github.com/deadsnakes/

Nightly Builds
==============

For nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly
 Más información: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
Pulse [ENTRAR] para continuar o Ctrl+C para cancelar la adición.

0% [Trabajando]
Obj:1 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu focal InRelease
Obj:2 http://es.archive.ubuntu.com/ubuntu focal InRelease
Obj:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease        
Des:4 http://es.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]  
Des:5 http://es.archive.ubuntu.com/ubuntu focal-backports InRelease [98,3 kB]
Des:6 http://es.archive.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Des:7 http://es.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [229 kB]
Des:8 http://es.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [205 kB]
Des:9 http://es.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [2.468 B]
Des:10 http://es.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [1.764 B]
Des:11 http://es.archive.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24,3 kB]
Des:12 http://es.archive.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [56,6 kB]
Descargados 835 kB en 2s (440 kB/s)                                    
Leyendo lista de paquetes... Hecho
jordiba90@lts:~/Descargas/Python-3.9.0$ 
jordiba90@lts:~/Descargas/Python-3.9.0$ sudo apt-get update
Obj:1 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu focal InRelease
Obj:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease
Obj:3 http://es.archive.ubuntu.com/ubuntu focal InRelease
Obj:4 http://es.archive.ubuntu.com/ubuntu focal-updates InRelease
Obj:5 http://es.archive.ubuntu.com/ubuntu focal-backports InRelease
Obj:6 http://es.archive.ubuntu.com/ubuntu focal-security InRelease
Leyendo lista de paquetes... Hecho
jordiba90@lts:~/Descargas/Python-3.9.0$ sudo apt-get install python3.9
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
python3.9 ya está en su versión más reciente (3.9.0-5~20.04).
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
jordiba90@lts:~/Descargas/Python-3.9.0$ python3 --version
Python 3.8.5
jordiba90@lts:~/Descargas/Python-3.9.0$ 

【问题讨论】:

  • 我无法使用 Ubuntu 18.04 和 Python 3.9.0 进行复制。但是,与其在这个问题上花费太多时间,您可以在没有 --enable-optimizations 标志的情况下运行 ./configure,或者按照 dejdej 的建议直接通过数据包管理器安装。
  • 我在清理格式时不得不猜测一些事情;请查看。
  • 您所遵循的指南不适用于 3.9,但您尝试使用的这个 configure 命令显然也适用于 3.9。错误消息看起来您只是有错误的configure 脚​​本。你确定它是 3.9 压缩包中的那个吗?
  • 我真的很抱歉三重奏,但我试图根据我所做的来指定和详细说明一个问题,我认为它并没有含糊。您对新手似乎非常全面,所以请确保我会受到激励再次参加这里..谢谢,真的。
  • 最后一个命令有效,但它没有取代python3。如果你想让它成为默认的 Python 3 系统范围,可以尝试 python3.9 --versionupdate-alternatives

标签: python ubuntu-20.04


【解决方案1】:

你有什么原因要从源代码安装 python 吗?

否则只需使用包管理器安装它:

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.9

【讨论】:

  • 这个问题是software-properties-common安装了python 3.8,然后你在系统中有2个版本
猜你喜欢
  • 2021-04-15
  • 2021-04-11
  • 1970-01-01
  • 2020-11-08
  • 2022-01-18
  • 2021-05-05
  • 2022-06-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多