Làm cách nào để cài đặt Python 3.7 trên CentOS 7?

Trong bài đăng này, tôi sẽ thực hiện cài đặt Python 3. 7 và tất cả các phụ thuộc của nó trên CentOS. Không giống như Ubuntu, Python không thể truy cập dễ dàng bằng trình quản lý gói 'yum' trên CentOS. Do đó, trước tiên chúng ta cần cài đặt một vài gói trước khi cài đặt Python

$ sudo yum groupinstall -y "Development Tools"

$ sudo yum install –y gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel gdbm-devel ncurses-devel db4-devel wget

Bây giờ chúng tôi đã cài đặt tất cả các phụ thuộc, chúng tôi cần tải xuống Python mới nhất từ ​​​​trang web của nó, https. //www. con trăn. org/tải xuống/

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz

Sau đó, chúng ta cần giải nén các tệp từ kho lưu trữ và định cấu hình cài đặt

$ tar -xzvf Python-3.7.4.tgz

$ sudo sh Python-3.7.4/configure --enable-optimizations

Cuối cùng, chúng tôi chạy lệnh sau để cài đặt Python

$ sudo make altinstall

Python của bạn hiện đã được cài đặt trong thư mục sau. /usr/local/bin/

Theo tùy chọn, bạn có thể tạo một liên kết để truy cập Python của mình bằng lệnh python3

$ sudo ln -s /usr/local/bin/python3.7 /usr/bin/python3

$ sudo ln -s /usr/local/bin/pip3.7 /usr/bin/pip3

Lưu ý, nếu bạn không thể truy cập Python bằng cách gõ “python3”, bạn có thể cần thêm dòng sau vào. tập tin bashrc

Python là một ngôn ngữ lập trình thông dịch, cấp cao, có mục đích chung. Đây là một trong những ngôn ngữ lập trình phổ biến nhất trên thế giới. Và nó rất dễ học cho người mới bắt đầu. Bạn có thể sử dụng python để phát triển trang web, khung tự động hóa hoặc phân tích dữ liệu, v.v. Nó có thể làm bất cứ điều gì mà bạn muốn cho đến nay. Đặc biệt, bạn có thể sử dụng nó để viết các tập lệnh trình thu thập thông tin

Python là ngôn ngữ lập trình hướng đối tượng có mục đích chung và nó được thiết kế để sử dụng như một giải pháp phần mềm cho hầu hết các loại yêu cầu.
Trăn 2. 7. 5 được cài đặt mặc định trên CentOS 7. Và phiên bản mới nhất của Python 3. 7 chưa được cài đặt và nó cũng không có sẵn trong kho yum chính thức của CentOS 7. Bạn cần thêm kho lưu trữ gói Ổn định ngược dòng (IUS) nội tuyến để cài đặt Python 3 bằng trình quản lý gói yum.

Tại thời điểm viết bài này, phiên bản ổn định mới nhất của Python3 là 3. 7. 3. Và phiên bản mới này sử dụng nhiều tính năng mới, bao gồm. Đánh giá hoãn lại các chú thích loại, không đồng bộ và chờ đợi hiện là các từ khóa dành riêng, mô-đun thư viện lớp dữ liệu và vars ngữ cảnh mới, Hàm điểm dừng mới, v.v. Nếu bạn muốn nhận thêm nhiều tính năng mới, chỉ cần xem Có gì mới trong Python 3. 7 trang

Bài đăng này sẽ chỉ cho bạn ba phương pháp cài đặt phiên bản 3 mới nhất. 7. 3 của Python trên hệ thống CentOS của bạn

Phương pháp1. Cài đặt Python3 từ Kho lưu trữ gói IUS


Vì gói Python3 mới nhất không có sẵn trên kho lưu trữ Yum mặc định, vì vậy bạn cần thêm kho lưu trữ gói ổn định Inline Upstream. IUS là một dự án cộng đồng và nó cung cấp các gói Trình quản lý gói Red Hat cho một số phiên bản phần mềm chọn lọc mới hơn, do đó, nó có thể cung cấp các gói RPM cần thiết, chẳng hạn như. Python3

Bước 1. Cài đặt gói IUS để thêm kho lưu trữ IUS vào hệ thống CentOS của bạn, gõ

$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm

đầu ra

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!

Bước 2. Khi gói IUS được cài đặt và bạn có thể cài đặt Python3. 6. 8 bằng lệnh sau

$ sudo yum update
$ sudo yum install python36u

đầu ra

________số 8

Bước 3. Sau khi quá trình cài đặt hoàn tất. Và bạn có thể chỉ cần kiểm tra xem phiên bản Python chính xác đã được cài đặt hay chưa bằng lệnh sau

$ python3.6 -V

đầu ra

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
0

Bây giờ là Python 3. 6. 8 nên được cài đặt trên hệ thống CentOS 7 của bạn

Phương pháp2. Cài đặt Python3 từ Mã nguồn


Nếu bạn muốn cài đặt phiên bản mới nhất 3. 7. 3 của Python trên hệ thống CentOS của bạn, bạn phải biên dịch mã nguồn Python theo cách thủ công. Và bạn cần tải xuống Python3. 7 gói nguồn từ trang web chính thức của họ. Sau đó, bạn cần biên dịch và cài đặt nó. Chỉ cần làm các bước sau

Bước 1. Bạn cần cài đặt các công cụ phát triển để biên dịch mã nguồn Python (chẳng hạn như. Trình biên dịch GCC). Loại

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
1

Hoặc là

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
2

Bước 2. tải xuống phiên bản mới nhất của mã nguồn Python từ trang web chính thức của Python bằng lệnh wget sau

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
3

đầu ra

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
4

Bước 3. giải nén gói Python đã tải xuống bằng lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
0

Bước 4. Thay đổi thư mục hiện tại thành Python-3. 7. 3, sau đó biên dịch mã nguồn Python bằng lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
1

Ghi chú. bạn không sử dụng lệnh make install tiêu chuẩn để biên dịch và cài đặt mã nguồn Python, vì lệnh này sẽ ghi đè lên tệp nhị phân python3 mặc định của hệ thống. make altinstall có thể được sử dụng để ngăn thay thế tệp nhị phân python mặc định.
–kích hoạt tối ưu hóa. Cho phép tối ưu hóa ổn định, đắt tiền (PGO, v.v.).

Bước5. Trăn 3. 7. 3 nên được cài đặt trên hệ thống của bạn, bạn có thể kiểm tra xem nó đã được cài đặt thành công hay chưa bằng cách kiểm tra phiên bản mới nhất được cài đặt bằng lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
2

đầu ra

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
3

Phương pháp3. Cài đặt Python3 với SCL


Bạn cũng có thể sử dụng tiện ích SCL để cài đặt phiên bản Python3 mới nhất trên CentOS 7 của mình. Chỉ cần làm các bước sau

Bước 1. bạn cần cập nhật trình quản lý gói để làm mới chỉ mục gói nhằm đảm bảo rằng kho lưu trữ yum được cập nhật, hãy nhập lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
4

Bước 2. bạn cần cài đặt SCL, viết tắt của Software Collections, và là một dự án mã nguồn mở cho phép bạn xây dựng, cài đặt và sử dụng nhiều phiên bản phần mềm trên cùng một hệ thống. Để kích hoạt SCL, bạn cần cài đặt gói centos-release-scl bằng cách chạy lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
5

Bước 3. bạn có thể truy cập vào kho lưu trữ SCL để cài đặt bất kỳ python3 nào. x mà bạn cần trên hệ thống CentOS của mình. Bây giờ nó có thể được sử dụng để cài đặt python3. 6 bằng lệnh sau

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
6

Bước 4. Sau khi cài đặt, bạn cần khởi chạy Python36 trong trình bao SCL mới, nhập

[devops@localhost ~]$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, langpacks
ius-release.rpm | 8.2 kB 00:00:00
Examining /var/tmp/yum-root-3dzYDD/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-3dzYDD/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Processing Dependency: epel-release = 7 for package: ius-release-2-1.el7.ius.noarch
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
ius-release noarch 2-1.el7.ius /ius-release 4.5 k
Installing for dependencies:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total size: 19 k
Total download size: 15 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY:--:-- ETA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/2
Installing : ius-release-2-1.el7.ius.noarch 2/2
Verifying : ius-release-2-1.el7.ius.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2

Installed:
ius-release.noarch 0:2-1.el7.ius

Dependency Installed:
epel-release.noarch 0:7-11

Complete!
7

Ghi chú. lệnh trên sẽ thực thi tập lệnh shell /opt/rh/rh-python36/enable, nó sẽ thay đổi các biến môi trường shell

Làm cách nào để cài đặt Python 3 trên Linux CentOS 7?

Rất may, kể từ CentOS 7. 7, Python 3 có sẵn trong kho gói cơ sở. .
Bước 1. Cập nhật môi trường
Bước 2. Cài đặt Python3
xác minh cài đặt
Bước 1. Thiết lập môi trường
Bước 2. Tải xuống Python
Bước 3. Cài đặt Python3

Cách cài đặt pip cho Python 3. 7 CentOS?

Cách cài đặt tiện ích PIP3 trên Linux(RHEL/CentOS 7/8) .
Bước 1. điều kiện tiên quyết. .
Bước 2. Cập nhật máy chủ của bạn. .
Bước 3. Cài đặt công cụ PIP3 trên Linux. .
Bước 4. Xác minh cài đặt gói PIP3. .
Bước 5. Kiểm tra phiên bản PIP3. .
Bước 6. Cài đặt Mô-đun Python bằng PIP3. .
Bước 7. Gỡ cài đặt Mô-đun Python bằng PIP3

Làm cách nào để thay đổi phiên bản Python trong CentOS 7?

Cách cài đặt Python 3. 11 trên CentOS .
Bước 1. Cập nhật CentOS. Bước đầu tiên, như mọi khi, là cập nhật hệ thống của bạn bằng lệnh sau. cập nhật yum
Bước 2. Cài đặt các gói cần thiết. .
Bước 3. Tải xuống Python. .
Bước 4. Cài đặt Python3. 11

Làm cách nào để cài đặt Python mới nhất trong CentOS 7?

Cách cài đặt phiên bản Python 3 mới nhất trên CentOS 7 .
Truy cập vào tài khoản người dùng với đặc quyền sudo. .
Xác minh rằng bạn đã cài đặt thành công Python 3 với. python3 --version. .
Lựa chọn 2. Cài đặt Python từ mã nguồn. .
Tiếp theo, sử dụng lệnh wget để tải xuống phiên bản Python mong muốn