python3.7.5一键安装脚本install_python3.7.5.sh,适用于linuix环境。内容如下:
which python3.7
if [[ $? = 0 ]];then
echo python3.7 exists
return 0
fi
[ ! -f Python-3.7.5.tgz ] && wget https://mirrors.huaweicloud.com/python/3.7.5/Python-3.7.5.tgz --no-check-certificate
tar xvf Python-3.7.5.tgz
cd Python-3.7.5
./configure --prefix=/usr/local/python3.7.5 --enable-shared
make -j4
make install
python_path='/usr/lib64/python3.7/site-packages/:/usr/lib/python3.7/site-packages:/usr/lib64/python3.7/lib-dynload'
if [[ -z $(cat ~/.bashrc |grep ${python_path}) ]];then
echo "set PYTHONPATH"
echo "export PYTHONPATH=${python_path}:$PYTHONPATH" >> ~/.bashrc
source ~/.bashrc
fi
#soft link
ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3
# env
echo 'export PATH=/usr/local/python3.7.5/bin/:$PATH' >>/etc/profile
echo 'export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH' >>/etc/profile
# refresh
source /etc/profile
# verify
python3 -V
pip3 -V
python3.7 --version
pip3.7 --version
cd ../
另附完全卸载Python指令:
# 卸载自动Python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
# 删除残余文件
whereis python |xargs rm -frv