和大家技术分享一下当我们安装完成Centos7后,默认系统Python的版本为2.7.5。我们希望将Python升级到最新版本。
1、安装依赖项
yum install -y openssl-devel openssl-static zlib-devel lzma tk-devel xz-devel bzip2-devel ncurses-devel gdbm-devel readline-devel sqlite-devel gcc libffi-devel
2、下载最新版Python
3、创建Download目录
Mkdir /usr/Downloads
Cd /usr/Downloads
Wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
3.1、如果wget没有安装的话会提示“-bash: Wget: command not found”,安装wget即可
yum install wget -y
4、将下载下来的压缩包进行解压
tar -xzvf Python-3.7.4.tgz
5、将解压后的文件移动到/usr/local路径下
mv Python-3.7.4 /usr/local
6、进入到Python目录下进行编译安装
./configure
make && make install
7、移动Python路径并修改软链接
mv /usr/bin/python /usr/bin/python3.7.4
ln -s /usr/local/Python-3.7.4/python /usr/bin/python
8、输入python回车后,我们会发现版本已经升级到最新了
[root@localhost /]# python
Python 3.7.4 (default, Aug 14 2019, 15:11:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
此文章为原创文章,作者:胖哥叨逼叨,如若转载,请与我联系并注明出处:https://www.pangshare.com/1656.htm