Centos 7.6安装python3.7
保留原有python2更新pip
| yum install epel-release -y yum -y install python-pip
pip install --upgrade pip
pip -V(大写V) //pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
|
若安装失败则手动更新
| sudo yum remove python-pip
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py sudo python get-pip.py
|
安装python3
安装依赖包
| yum install libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make yum install libffi-devel -y
|
下载python3
| wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz //按需求修改版本号
|
解压
| tar -xvJf Python-3.7.2.tar.xz
|
安装
| cd Python-3.7.2 ./configure prefix=/usr/local/python3 make && make install
|
安装完毕,/usr/local/目录下就会有python3了。
配置python3
| ln -s /usr/local/python3/bin/python3 /usr/bin/python3
python3 --version
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
pip3 install --upgrade pip
pip3 -V
|
设置yum使用python2