1.安装python3.7可能使用的依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
2.到python官网找到下载路径, 用wget下载
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
3.解压tgz包
[root@hadoop-slave1 tmp]#tar -zxvf Python-3.7.9.tgz
[root@hadoop-slave1 tmp]# cd Python-3.7.9
4.编译安装
进入python目录
cd /tmp/Python-3.7.9
./configure --prefix=/usr/local/python37 && make && make install
指定安装目录:/usr/local/python37
-----------------安装沙盒环境---------------------
安装虚拟环境
[root@hadoop-slave1 local]# cd /usr/local/python37/bin
[root@hadoop-slave1 local]#./pip3 install virtualenv
使用virtualenv创建沙盒环境
mkdir -p /home/hxl/cmdb/
[root@k8s-node1 /]#cd /home/hxl/cmdb
[root@hadoop-slave1 python37-venv]# /usr/local/python37/bin/virtualenv python37-venv
使用沙盒环境
[root@hadoop-slave1 scripts]#source /home/hxl/cmdb/python37-venv/bin/activate
(python37-venv) [root@hadoop-slave1 scripts]#
退出沙盒环境
[root@hadoop-slave1 scripts]#deactivate
原文:https://www.cnblogs.com/hxlasky/p/13785676.html