Skip to main content
  1. Documentation/

Centos7 install python and pip

77 words·1 min
Python
Table of Contents

从源代码编译安装
#

安装构建 Python 所需的依赖包

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

下载 Python 源代码
#

cd /usr/src
sudo wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

解压 Python 源代码 & 编译安装
#

sudo tar xzf Python-3.9.1.tgz
cd Python-3.9.1
sudo ./configure --enable-optimizations
sudo make altinstall

使用 altinstall 而不是 install,以避免覆盖系统的默认 Python 版本

安装 pip

sudo python3.9 -m ensurepip

验证 Python 和 pip 版本

python3.9 -V
# Python 3.9.1

pip3.9 -V
# pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

Related

Format python Code
38 words·1 min
Python
Format python code # # install autopep8 pip3 install autopep8 # format code and overwriting the original code autopep8 --in-place --aggressive --aggressive test.
Ansible: Failed to connect to the host via ssh: Permission denied
410 words·2 mins
Ansible
Failed to connect to the host via ssh: Permission denied # 需要设置免密通信, 通过ssh-keygen命令执行生成密钥对
Centos7: 误删python2导致yum无法使用
219 words·2 mins
Linux
uninstall python # 优先卸载,确保环境干净
Centos7 换源&更新网络连接
151 words·1 min
Linux
Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64 # reset /etc/yum.
Go Version Manager (GVM)
88 words·1 min
Golang
GVM(Go Version Manager)是一款用于管理和切换不同Go语言版本的工具 Install # bash < <(curl -s -S -L https://raw.