升级python2.7, 实现python2.7与python3并存
由于用到twilio模块, 所以需要升级一下python2, 但是又不想舍弃python2, 于是实现了简单的方法
python
先扔一块依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
先download一个压缩包
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
新建文件夹
mkdir /usr/local/python3
解压
tar -xvJf Python-3.6.2.tar.xz
编译与安装
./configure --prefix=/usr/local/python3/ && make && make install
软链接
mv /usr/bin/python /tmp && ln -s /usr/local/python3/bin/python3 /usr/bin/python
改配置
vim /usr/bin/yum
把#! /usr/bin/python修改为#! /usr/bin/python2
vim /usr/libexec/urlgrabber-ext-down
把#! /usr/bin/python修改为#! /usr/bin/python2
[root@localhost~]# python -V Python 3.6.2 [root@localhost~]# python2 -V Python 2.7.5 [root@localhost~]#
OK
pip
顺道说一下, yum升级pip有点愚蠢
扔一个升级py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
run
python get-pip.py
OK!
pip
pip install twilio