1. 系统环境
CentOS 7.6
自带了Python2.7.5
,我们需要另行安装Python 3.8.3
2. 下载依赖包
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
3. 下载安装包
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
4. 安装步骤
- 解压
tar -zxvf Python-3.8.3.tgz
- 进入解压目录
cd Python-3.8.3
- 配置安装位置
./configure --prefix=/usr/local/python3
- 安装
make && make install
安装成功后,/usr/local/
目录下就会生成python3
目录
5. 添加软连接
- 添加
python3
的软链接
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
- 添加
pip3
的软链接
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
6. 测试
7. 配置国内pip源
国内常用pypi
源:
中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云:https://mirrors.aliyun.com/pypi/simple/
豆瓣:https://pypi.douban.com/simple/
步骤如下:
# 创建.pip目录
mkdir ~/.pip
# 进入.pip目录下
cd ~/.pip
# 创建pip.conf文件
vim pip.conf
pip.conf
文件内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
最后:对你有所帮助的话,记得点赞哦!