說起環境搭建估計是頭疼的,俗話說,萬事開頭難
今天就說一下 linux Python2.7到3.6的升級
PYTHON
第一步:查看當前版本
python -V
第二步:安裝依賴
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc
第三步:下載python36
sudo yum install tops-python36 -b current
(這個python是安裝在/home/tops/bin 下面)
第四步:修改舊版本
`mv /usr/bin/python /usr/bin/python_bak`
(做一個備份)
第五步:軟連接 Python 安裝完成
ln -s /home/tops/bin/python3 /usr/bin/python
PIP配置
編輯配置文件
vim ~/.bash_profile
修改內容
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/home/tops/bin
export PATH)
最後啓動
source ~/.bash_profile
此時yum是不能用的
這個時候我們只需要修改yum配置文件,將python版本只想以前的舊版就可以了
#vi /usr/bin/yum
首行 #! /usr/bin/python
改成 #! /usr/bin/python2.7
:wq!
看看看看