在Ubuntu 20.04上安装Python 3.9时出错>已解决

时间:2020-11-08 12:26:15

标签: python ubuntu-20.04

我想在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

无论我尝试什么,都会遇到很多其他错误。也许是关于我的操作系统上配置的问题。

我希望不会在这个问题上违反堆栈规则,但是我真的不知道该如何处理。

PS:Python 3.9上的文件如下:

  • aclocal.m4
  • config.sub
  • 语法
  • 许可
  • 其他
  • 解析器
  • pyconfig.h.in
  • 工具CODE_OF_CONDUCT.md
  • 配置
  • 包含
  • m4
  • 模块
  • PC
  • Python
  • config.guess
  • configure.ac
  • install-sh
  • Mac
  • netlify.toml
  • PCbuild
  • README.rstconfig.log
  • 文档
  • Makefile.pre.in
  • 对象
  • 程序
  • setup.py

PS_2:我有Python 3.8,我想安装3.9,但出现很多错误。从源代码安装是我上次所做的,而且很容易。

我只是试过了,所以不起作用。

PS_3:我尝试使用软件包管理器进行安装,结果是一样的,请给我更多的声誉,但可以帮助新手了解我做错了什么

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$ 

1 个答案:

答案 0 :(得分: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