1. 安装依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel epel-release
#yum -y install python3-pip
2. 下载源码包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz tar -xf Python-3.7.0.tgz cd Python-3.7.0.tgz ./configure prefix=/soft/python3 make && make install
3. 添加软连接
ln -s /soft/python3/bin/python3.7 /usr/bin/python3 ln -s /soft/python3/bin/pip3.7 /usr/bin/pip3
4. 配置虚拟环境
python3 -m venv py37
source py37/bin/activate
# pip 管理包
pip3 list pip3 freeze pip3 install requests==2.6.0 # 指定版本安装 pip3 search/install/uninstall soft_name pip3 freeze > requirements.txt pip3 install -r requirements pip3 install --upgrade soft_name
使用国内开源镜像站点:
mkdir ~/.pip/ vim ~/.pip/pip.conf [global] index-url=http://pypi.douban.com/simple/ [install] trusted-host=pypi.douban.com
安装pip
$ wget https://bootstrap.pypa.io/get-pip.py $ python get-pip.py $ pip -V #查看pip版本