centos7升级Python

由于Python2X系列已于2020-1-1不在进行维护了,所以将系统Python版本升级到python3X系列

#查看当前的Python版本
[root@fengzhilaoling ~]# python --version
Python 2.7.5
下载Python的Linux安装包
#本次安装为3.6.8  以为Python3.7与3.8还不是稳定版,所以选择稳定版的3.6
 wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
安装依赖的软件包
#这步最好做,不然后期做一些其他操作是Python可能缺少某些支持,修复起来很麻烦
yum -y groupinstall "Development tools"
yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel libffi-devel
开始安装
tar xf Python-3.6.8.tgz 
cd Python-3.6.8
./configure --prefix=/usr/local/python3
make & make install
配置Python3的环境
ln -s /usr/local/python3/bin/python3.6 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin

#测试一下
 python3
Python 3.6.8 (default, May 11 2020, 10:10:00) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
方便以后以交互的方式执行代码(python shell)安装ipython
pip3 install ipython
#如果出现错误根据提示安装依赖的Python模块
#安装完后ipyth在/usr/local/python3/bin下,我们在做一次软连接
ln -s /usr/local/python3/bin/ipython /usr/bin/ipython
#测试一下
 ipython
/usr/local/python3/lib/python3.6/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
  warn("IPython History requires SQLite, your history will not be saved")
Python 3.6.8 (default, May 11 2020, 10:10:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值