1.安装相应的编译工具
在root用户下,全部复制粘贴过去,一次性安装即可.
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y
2.下载安装包
wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
3.解压
tar -xvJf Python-3.7.7.tar.xz
4.创建编译安装目录
mkdir /usr/local/python3
5.安装
cd Python-3.7.7
./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
make && make install
6.创建软链接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
7.验证是否成功
python3 -V
pip3 -V
8.修改pip安装源
修改系统pip安装源
在家目录下新建.pip文件夹,进入文件夹新建文件pip.conf之后写入相应镜像网站地址
cd ~
mkdir .pip
cd .pip
vim pip.conf
进入后添加以下内容,保存退出.
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
9.修改pipenv安装源
在自己的虚拟环境中找到Pipfile文件,将其中的url = "https://pypi.org/simple"修改为你需要的国内镜像,如https://mirrors.aliyun.com/pypi/simple/
[[source]]
name = "pypi"
url = "https://pypi.org/simple" # 改为url = "https://mirrors.aliyun.com/pypi/simple/"
verify_ssl = true