python35是什么意思_python -m是什么意思CentOS 升级 Python3 (附带: 一键升级脚本)...
一鍵安裝腳本(附帶)
電腦技術(shù)網(wǎng)從python -m是什么意思CentOS 升級(jí) Python3 (附帶: 一鍵升級(jí)腳本)分析來(lái)看,對(duì)python -m是什么意思CentOS 升級(jí) Python3 (附帶: 一鍵升級(jí)腳本)的結(jié)果。
#!/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}"
# 網(wǎng)絡(luò)檢查
NETWORK_CHECK() {
# 檢查聯(lián)網(wǎng)情況
ping www.baidu.com -c 3
if [ $? != 0 ];then
Echo_Red "該服務(wù)器無(wú)法連網(wǎng),請(qǐng)配置服務(wù)器網(wǎng)絡(luò)!"
exit 1
fi
}
# 升級(jí) Python
PYTHON_UPDATE() {
# 檢查網(wǎng)絡(luò)
NETWORK_CHECK
# 安裝依賴(lài)
Echo_Green '安裝依賴(lài):'
yum -y install zlib-devel bzip2-devel wget openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
# 檢查 Python 版本
Echo_Green '當(dāng)前版本 Python:'
Echo_Yellow "==========================================================================="
/usr/bin/python -V
Echo_Yellow "==========================================================================="
# 確認(rèn)升級(jí)
read -p "是否繼續(xù)升級(jí) Python [y/n]:" Chose_Number
case ${Chose_Number} in
[yY][eE][sS]|[yY])
Echo_Yellow "你選擇的是yes,升級(jí)繼續(xù)進(jìn)行..."
;;
[nN][oO]|[nN])
Echo_Yellow "你選擇的是yes,升級(jí)即將終止..."
exit
;;
*)
Echo_Red "輸入錯(cuò)誤,即將退出升級(jí)..."
exit
esac
# 檢測(cè)包是否存在
ls -l ${Package_Dir}/${Python_Package}
if [ $? != 0 ];then
# 下載安裝包
Echo_Yellow "開(kāi)始從網(wǎng)上下載 ${Python_Package}..."
wget ${Python_Url}
if [ $? != 0 ];then
Echo_Red "網(wǎng)上下載 ${Python_Package} 失敗,請(qǐng)檢查!"
exit 1
fi
Echo_Yellow "${Python_Package} 下載成功,即將開(kāi)始升級(jí)..."
fi
# 解壓安裝
Echo_Yellow "開(kāi)始解壓 Python ..."
tar -zxf ${Python_Package} && cd Python-${Python_Version}
if [ $? != 0 ];then
Echo_Red "${Python_Package} 解壓失敗,請(qǐng)檢查!"
exit 1
fi
Echo_Yellow "開(kāi)始配置 Python ..."
./configure --prefix=${Python_Install_Dir} --enable-shared CFLAGS=-fPIC
if [ $? != 0 ];then
Echo_Red "${Python_Package} 解壓失敗,請(qǐng)檢查!"
exit 1
fi
Echo_Yellow "開(kāi)始編譯 Python ..."
make -j 4
if [ $? != 0 ];then
Echo_Red "${Python_Package} 編譯失敗,請(qǐng)檢查!"
exit 1
fi
Echo_Yellow "開(kāi)始安裝 Python ..."
make install
if [ $? != 0 ];then
Echo_Red "${Python_Package} 安裝失敗,請(qǐng)檢查!"
exit 1
fi
# 配置環(huán)境變量
Echo_Yellow "修改環(huán)境變量 ..."
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
# 修改庫(kù)文件
Echo_Yellow "修改 Python 庫(kù)文件 ..."
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
# 查看升級(jí)后版本
Echo_Green '當(dāng)前版本 Python(建議手動(dòng)執(zhí)行: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 '備注:詳情可以聯(lián)系QQ:1214966109'
Echo_Green ''
Echo_Yellow "==========================================================================="
Echo_Green ''
Echo_Yellow '升級(jí)即將開(kāi)始...'
Echo_Green ''
sleep 2
# 升級(jí)
PYTHON_UPDATE
更多:python -m是什么意思CentOS 升級(jí) Python3 (附帶: 一鍵升級(jí)腳本)
https://www.002pc.comhttps://www.002pc.com/python/1052.html
你可能感興趣的升級(jí),CentOS,Python3,一鍵,附帶,腳本
No alive nodes found in your cluster
0踩
賞
0 贊
總結(jié)
以上是生活随笔為你收集整理的python35是什么意思_python -m是什么意思CentOS 升级 Python3 (附带: 一键升级脚本)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python 廖雪峰_廖雪峰的Pytho
- 下一篇: python3断言_Python3断言