如何在 Amazon Linux 2 上安装 Python 3.9如何在 Amazon Linux 2 上安装 Python 3.9如何在 Amazon Linux 2 上安装 Python 3.9如何在 Amazon Linux 2 上安装 Python 3.9
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

如何在 Amazon Linux 2 上安装 Python 3.9

发表 admin at 2025年2月28日
类别
  • 未分类
标签

你好,了不起的人们!在今天的文章中,我们将在 Amazon Linux 2 上安装 Python 3.9。Python 是一种开源、功能强大且易于掌握的编程语言。它在数据科学、机器学习和人工智能领域非常流行。尽管它的开发最初是作为一个业余爱好项目,但现在它已成为世界上广泛使用的编程语言。 Python 被创建为简单、高效,但具有有效的面向对象编程方法。

Python 3.9 于 2020 年 10 月 5 日首次发布,预计将于 2025 年 10 月结束支持。以下是 Python 3.9 版本中提供的一些关键功能。

  • PEP 573,从 C 扩展方法访问模块状态
  • PEP 584,将工会运营商添加到字典中
  • PEP 585,标准集合中的类型提示泛型
  • PEP 593,灵活的函数和变量注释
  • PEP 614,放宽装饰器的语法限制
  • PEP 615,标准库中对 IANA 时区数据库的支持
  • PEP 616,删除前缀和后缀的字符串方法
  • PEP 617,CPython 的新 PEG 解析器

在 Amazon Linux 2 上安装 Python 3.9

在这篇博文中,我们将在 Amazon Linux 2 系统上执行安装 Python 3.9 的安装。许多库都可以从 https://www.python.org/ 免费获取适用于所有主要平台的源代码。它们使您能够扩展 Python 功能。

安装 Python 构建依赖项

从源代码在 Amazon Linux 2 上构建 Python 3.9 需要许多依赖项。通过在终端中运行以下命令来安装它们

sudo yum -y groupinstall "Development Tools"
sudo yum -y install openssl-devel bzip2-devel libffi-devel

验证 gcc 并进行工具安装

$ gcc --version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-13)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make --version
GNU Make 3.82
Built for x86_64-koji-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

下载并构建 Amazon Linux 2 上的 Python 3.9

下载

sudo yum -y install wget
wget https://www.python.org/ftp/python/3.9.17/Python-3.9.17.tgz

提取下载的文件

tar xvf Python-3.9.17.tgz

构建并安装

cd Python-*/
./configure --enable-optimizations
sudo make altinstall

如果安装

$ python3.9 --version
Python 3.9.17

Pip 也通过 Python 3.9 安装在您的系统上

$ pip3.9 --version
pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

升级点

$ /usr/local/bin/python3.9 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (21.2.4)
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 11.1 MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1

使用pip3.9测试模块安装

$ pip3.9 install awscli --user
Collecting awscli
  Downloading awscli-1.22.13-py3-none-any.whl (3.8 MB)
     |████████████████████████████████| 3.8 MB 26.4 MB/s
Collecting rsa<4.8,>=3.1.2
  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting PyYAML<5.5,>=3.10
  Downloading PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl (630 kB)
     |████████████████████████████████| 630 kB 38.2 MB/s
Collecting botocore==1.23.13
  Downloading botocore-1.23.13-py3-none-any.whl (8.2 MB)
     |████████████████████████████████| 8.2 MB 31.7 MB/s
Collecting docutils<0.16,>=0.10
  Downloading docutils-0.15.2-py3-none-any.whl (547 kB)
     |████████████████████████████████| 547 kB 39.1 MB/s
Collecting colorama<0.4.4,>=0.2.5
  Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting s3transfer<0.6.0,>=0.5.0
  Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 17.6 MB/s
Collecting jmespath<1.0.0,>=0.7.1
  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting python-dateutil<3.0.0,>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 34.5 MB/s
Collecting urllib3<1.27,>=1.25.4
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 38.2 MB/s
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 13.6 MB/s
Installing collected packages: six, urllib3, python-dateutil, jmespath, pyasn1, botocore, s3transfer, rsa, PyYAML, docutils, colorama, awscli
Successfully installed PyYAML-5.4.1 awscli-1.22.13 botocore-1.23.13 colorama-0.4.3 docutils-0.15.2 jmespath-0.10.0 pyasn1-0.4.8 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.5.0 six-1.16.0 urllib3-1.26.7

这证实我们在 Amazon Linux 2 上成功安装了 Python 3.9 和 Pip3.9。您可以在我们的网站上查看有关 Amazon Linux 2 的更多指南。

  • 如何在 Amazon Linux 2 上安装 Python 3.10
  • 在 Amazon Linux 2 上安装 Java 17 (OpenJDK 17)
  • 如何在 Amazon Linux 2 上安装 MongoDB 5.0
©2015-2025 Norria support@alaica.com