CentOS 7.x升级默认python2.7版本到3.5.2

原创 楚盟  2017-11-22 04:43  阅读 360 views 次

一:Python下载站点:
https://www.python.org/ftp/python/

二:安装


yum install gcc gcc-c++ openssl openssl-devel
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar -zxvf Python-3.5.2.tgz
cd  Python-3.5.2
./configure --prefix=/usr/local/python-3.5.2/
make -j `cat /proc/cpuinfo|grep processor|wc -l`
make install
cd ..

三:配置修改

修改默认的python 为 3.5.2
mv /usr/bin/python /usr/bin/python.bak.2.7
ln -s /usr/local/python-3.5.2/bin/python3.5 /usr/bin/python

yum行修改为python2.7
sed -i 's/bin\/python/bin\/python2.7/' /usr/bin/yum

or

vi /usr/bin/yum
#---------------------------
#!/usr/bin/python2.7
#---------------------------



yum关联文件
sed -i 's/bin\/python/bin\/python2.7/' /usr/libexec/urlgrabber-ext-down

or

vi /usr/libexec/urlgrabber-ext-down
#---------------------------
#!/usr/bin/python2.7
#---------------------------

python3默认已安装了pip 体系换系统默认的
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/python-3.5.2/bin/pip3 /usr/bin/pip

升级到最新版本
pip install --upgrade pip

替换系统easy_install 否则将不可用
mv /usr/bin/easy_install /usr/bin/easy_install.bak
ln -s /usr/local/python-3.5.2/bin/easy_install-3.5 /usr/bin/easy_install

本文来源于http://www.zhangluya.com/?p=221

本文地址:https://www.5yun.org/14693.html
关注我们:请关注一下我们的微信公众号:扫描二维码楚盟网的公众号,公众号:chubin5yun
版权声明:本文为原创文章,版权归 楚盟 所有,欢迎分享本文,转载请保留出处!

发表评论


表情