编译安#切换roosudo su#下载源码包
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
#解压源码包
tar -zxf Python-3.7.3.tgz
#切换目录
cd Python-3.7.3
#安装所需依赖包
apt install zlib*
apt install libffi-dev
apt install python-dev
apt install libffi-dev
apt install libssl-dev
#编译、安装 ./configure --prefix=/opt/python-3.7.3 make && make install
虚拟环境
#安装virtualenv
pip install virtualenv
#进入工程目录
cd my_project_dir
#为工程创建一个虚拟环境(-p参数指定Python解释器程序路径,venv为虚拟环境目录名,目录名自定义)
virtualenv -p /opt/python3.7/bin/python3.7 venv
#激活虚拟环境
source venv/bin/activate
#停用虚拟环境
deactivate