linux系统中存在Python情况共存安装新版Python及pip安装
参考 https://blog.csdn.net/wowocpp/article/details/80710984
安装setuptools,要需要安装zlib:
yum install zlib zlib-dev
为在python编译时加入ssl模块,yum安装openssl和openssl-devel
sudo yum install openssl
sudo yum install openssl-devel
sudo yum install ncurses-libs
sudo yum install readline-devel
sudo yum install sqlite-devel
sudo yum install bzip2-devel
sudo yum install gdbm-devel
sudo yum install libdbi-devel
下载解压
cd /usr/local/src
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar zvxf Python-2.7.13.tgz
配置
./configure --prefix=/usr/local/python27/
编译
sudo make
sudo make install
查看原来的连接
[root@slave6 bin]# ll /usr/bin/python*
lrwxrwxrwx 1 root root 33 Aug 21 14:51 /usr/bin/python -> /usr/local/python27/bin/python2.7
lrwxrwxrwx. 1 root root 6 Aug 12 11:34 /usr/bin/python2 -> python
修改连接
sudo mv /usr/bin/python2 /usr/bin/python2_old
sudo mv /usr/bin/python2.7 /usr/bin/python2.7.5
sudo mv /usr/bin/python /usr/bin/python_old
sudo ln -s /usr/local/python27/bin/python2.7 /usr/bin/python2
sudo ln -s /usr/bin/python2 /usr/bin/python
[root@slave6 bin]# python -V
Python 2.7.13
其中用到了 python2 的目的是 ,以后有可能会用到python3
/usr/bin/python2 和 /usr/bin/python2.7 应该需要删掉 因为有的python 脚本里面会注明使用 /usr/bin/python2
安装Python 2.7.13对应的pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
替换原来的pip
[root@slave6 src]# ll /usr/bin/pip*
sudo mv /usr/bin/pip /usr/bin/pip_old
sudo mv /usr/bin/pip2 /usr/bin/pip2_old
sudo mv /usr/bin/pip2.7 /usr/bin/pip2.7_old
sudo cp /usr/local/python27/bin/pip* /usr/bin/
[root@slave6 src]# pip -V
pip 18.1 from /usr/local/python27/lib/python2.7/site-packages/pip (python 2.7)
本文来自博客园,作者:zsls-lang,转载请注明原文链接:https://www.cnblogs.com/zsls-lang/p/10248511.html
行也思卿,坐也思卿
日高三竿我犹眠,不管人间万里愁