由于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.