安装python 3.5/3.8

环境:

OS:Centos 7

 

1.安装python3.5可能使用的依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc

 

2.到python官网找到下载路径, 用wget下载
wget

 

 

3.解压tgz包
tar -zxvf Python-3.5.1.tgz

 

4.把python移到/usr/local下面
mv Python-3.5.1 /usr/local

 

5.编译安装
进入python目录
cd /usr/local/Python-3.5.1/
./configure
make
make install

 

说明:

安装新版本的openssl需要指定新版本的路径,如下

./configure --with-openssl=/usr/local/openssl

升级openssl的方法如下:

https://www.cnblogs.com/hxlasky/p/18348968

 


6.删除旧的软链接,创建新的软链接到最新的python
rm -rf /usr/bin/python
rm -rf /usr/local/bin/python
ln -s /usr/local/bin/python3.5 /usr/bin/python
ln -s /usr/local/bin/python3.5 /usr/local/bin/python
[root@localhost bin]# python -V
Python 3.5.1

 

#########################################3.8.19###################################

 

1.解压tgz包
tar -zxvf Python-3.8.19.tgz

 

 

2.把python移到/usr/local下面
[root@host134 soft]# mv Python-3.8.19 /usr/local/

 

 

3.编译安装
进入python目录
[root@host134 soft]# cd /usr/local/Python-3.8.19/
[root@host134 soft]#./configure
[root@host134 soft]#make
[root@host134 soft]#make install

 

说明:

安装新版本的openssl需要指定新版本的路径,如下

./configure --with-openssl=/usr/local/openssl

 

升级openssl的方法如下:

 

https://www.cnblogs.com/hxlasky/p/18348968

 

 

4.删除旧的软链接,创建新的软链接到最新的python
rm -rf /usr/bin/python
rm -rf /usr/local/bin/python
ln -s /usr/local/bin/python3.8 /usr/bin/python
ln -s /usr/local/bin/python3.8 /usr/local/bin/python

 

[root@host134 Python-3.8.19]# python -V
Python 3.8.19

 

posted @ 2022-06-06 17:35  slnngk  阅读(939)  评论(0编辑  收藏  举报