python35是什么意思_python -m是什么意思CentOS 升级 Python3 (附带: 一键升级脚本)...
一鍵安裝腳本(附帶)
電腦技術網從python -m是什么意思CentOS 升級 Python3 (附帶: 一鍵升級腳本)分析來看,對python -m是什么意思CentOS 升級 Python3 (附帶: 一鍵升級腳本)的結果。
#!/bin/bash
######################################
## ##
## vers: 1.0 ##
## author: Dylan ##
## date: 20171027 ##
## useage: Update Python to 3.5 ##
## ##
######################################
#定義顏色輸出
Color_Text() {
echo -e " e[0;$2m$1e[0m"
}
Echo_Red() {
echo $(Color_Text "$1" "31")
}
Echo_Green() {
echo $(Color_Text "$1" "32")
}
Echo_Yellow() {
echo $(Color_Text "$1" "33")
}
# Python 版本
Python_Version='3.5.2'
# Python 安裝包
Python_Package="Python-${Python_Version}.tgz"
# Python 下載地址
Python_Url="http://mirrors.sohu.com/python/${Python_Version}/${Python_Package}"
# 包存放地址
Package_Dir=$(pwd)
# 安裝目錄
Python_Install_Dir="/usr/local/python-${Python_Version}"
# 網絡檢查
NETWORK_CHECK() {
# 檢查聯網情況
ping www.baidu.com -c 3
if [ $? != 0 ];then
Echo_Red "該服務器無法連網,請配置服務器網絡!"
exit 1
fi
}
# 升級 Python
PYTHON_UPDATE() {
# 檢查網絡
NETWORK_CHECK
# 安裝依賴
Echo_Green '安裝依賴:'
yum -y install zlib-devel bzip2-devel wget openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
# 檢查 Python 版本
Echo_Green '當前版本 Python:'
Echo_Yellow "==========================================================================="
/usr/bin/python -V
Echo_Yellow "==========================================================================="
# 確認升級
read -p "是否繼續升級 Python [y/n]:" Chose_Number
case ${Chose_Number} in
[yY][eE][sS]|[yY])
Echo_Yellow "你選擇的是yes,升級繼續進行..."
;;
[nN][oO]|[nN])
Echo_Yellow "你選擇的是yes,升級即將終止..."
exit
;;
*)
Echo_Red "輸入錯誤,即將退出升級..."
exit
esac
# 檢測包是否存在
ls -l ${Package_Dir}/${Python_Package}
if [ $? != 0 ];then
# 下載安裝包
Echo_Yellow "開始從網上下載 ${Python_Package}..."
wget ${Python_Url}
if [ $? != 0 ];then
Echo_Red "網上下載 ${Python_Package} 失敗,請檢查!"
exit 1
fi
Echo_Yellow "${Python_Package} 下載成功,即將開始升級..."
fi
# 解壓安裝
Echo_Yellow "開始解壓 Python ..."
tar -zxf ${Python_Package} && cd Python-${Python_Version}
if [ $? != 0 ];then
Echo_Red "${Python_Package} 解壓失敗,請檢查!"
exit 1
fi
Echo_Yellow "開始配置 Python ..."
./configure --prefix=${Python_Install_Dir} --enable-shared CFLAGS=-fPIC
if [ $? != 0 ];then
Echo_Red "${Python_Package} 解壓失敗,請檢查!"
exit 1
fi
Echo_Yellow "開始編譯 Python ..."
make -j 4
if [ $? != 0 ];then
Echo_Red "${Python_Package} 編譯失敗,請檢查!"
exit 1
fi
Echo_Yellow "開始安裝 Python ..."
make install
if [ $? != 0 ];then
Echo_Red "${Python_Package} 安裝失敗,請檢查!"
exit 1
fi
# 配置環境變量
Echo_Yellow "修改環境變量 ..."
echo "export PATH=$PATH:${Python_Install_Dir}/bin" >>/etc/profile
# 修改原有的 Python 為新的
Echo_Yellow "替換舊版 Python ..."
mv /usr/bin/python /tmp
ln -s ${Python_Install_Dir}/bin/python3 /usr/bin/python
# 修改庫文件
Echo_Yellow "修改 Python 庫文件 ..."
ldd ${Python_Install_Dir}/bin/python3
cp ${Python_Install_Dir}/lib/libpython3.5m.so.1.0 /lib64/
# 修改 yum 配置
Echo_Yellow "修改 yum 文件 ..."
sed -i "s#/usr/bin/python#/usr/bin/python2.6#g" /usr/bin/yum
# 使配置生效
source /etc/profile
# 查看升級后版本
Echo_Green '當前版本 Python(建議手動執行:source /etc/profile):'
Echo_Yellow "==========================================================================="
/usr/bin/python -V
Echo_Yellow "==========================================================================="
}
# 輸出安裝信息
Echo_Yellow "==========================================================================="
Echo_Green ''
Echo_Green '版本:1.0'
Echo_Green '作者:Dylan'
Echo_Green '日期:20171027'
Echo_Green '備注:詳情可以聯系QQ:1214966109'
Echo_Green ''
Echo_Yellow "==========================================================================="
Echo_Green ''
Echo_Yellow '升級即將開始...'
Echo_Green ''
sleep 2
# 升級
PYTHON_UPDATE
更多:python -m是什么意思CentOS 升級 Python3 (附帶: 一鍵升級腳本)
https://www.002pc.comhttps://www.002pc.com/python/1052.html
你可能感興趣的升級,CentOS,Python3,一鍵,附帶,腳本
No alive nodes found in your cluster
0踩
賞
0 贊
總結
以上是生活随笔為你收集整理的python35是什么意思_python -m是什么意思CentOS 升级 Python3 (附带: 一键升级脚本)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 廖雪峰_廖雪峰的Pytho
- 下一篇: python3断言_Python3断言