因服务器上需运行b站挂机脚本,而脚本要求py版本必须>=2.6.9
而系统自带的版本为 Python 2.6.6
于是就 Google 之顺便升级下,安装过程中出现了点问题,特此写下笔记
Once upon time,A few mistakes agoI was in your sights,You got me aloneYou found me, you found me, you found meI guess you didn't careAnd I guess I liked thatAnd when I fell hardYou took a step backWithout me, without me, without meAnd he's long goneWhen he's next to meAnd I realize the blame is on meCause I knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenTill you put me down ohI knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenNow I'm lying on the cold hard groundOh, oh, trouble, trouble, troubleOh, oh, trouble, trouble, troubleNo apologiesHe'll never see you cryPretends he doesn't knowThat he's the reason whyYou're drowning, you're drowning, you're drowningAnd I heard you moved onFrom whispers on the streetA new notch in your beltIs all I'll ever beAnd now I see, now I see, now I seeHe was long goneWhen he met meAnd I realize the joke is on meI knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenTill you put me down ohI knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenNow I'm lying on the cold hard groundOh, oh, trouble, trouble, troubleOh, oh, trouble, trouble, troubleAnd the saddest fear comes creeping inThat you never loved me or her or anyone or anythingYeahI knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenTill you put me down ohI knew you were trouble when you walked inSo shame on me nowFlew me to places I'd never beenNow I'm lying on the cold hard groundOh, oh, trouble, trouble, troubleOh, oh, trouble, trouble, troubleI knew you were trouble when you walked inTrouble, trouble, troubleI knew you were trouble when you walked inTrouble, trouble, trouble
I Knew You Were TroubleWalk off the Earth
1.首先查看 Python 的版本
python -V
Python 2.6.6
2.安装前准备 安装相关库
yum install gcc gcc-c++ autoconf automake
yum install openssl openssl-devel
3.下载 Python-2.7.12
wget http://python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
4.解压 Python-2.7.12.tar.xz
xz -d Python-2.7.12.tar.xz
tar xvf Python-2.7.12.tar
5.进入 Python-2.7.12 目录
cd Python-2.7.12
6.安装 Python-2.7.12
./configure
make
make install
7.查看版本信息
/usr/local/python2.7/bin/python -V
Python 2.7.12
8.建立软连接,使系统默认的 Python 指向 Python2.7
mv /usr/bin/python /usr/bin/python2.6.6.old
ln -s /usr/local/python2.7/bin/python /usr/bin/python
9.这时我们在查看下 Python 版本
python -V
Python 2.7.12
10、修改 yum 使用的 python 版本
虽然现在 python 已经安装完成,可是 yum 不兼容 Python 2.7 导致 yum 不能正常工作,所以我们需要到 yum 的配置文件中指定 Python 的版本为 2.6.6
vi /usr/bin/yum
将 #!/usr/bin/python
改成 #!/usr/bin/python2.6.6
然后 :wq
保存即可
python 升级后 原来的 pip 会不能用
需重新安装 pip
直接输入curl https://bootstrap.pypa.io/get-pip.py | python
即可安装
好了完结撒花~
这么长不打分割差评,直接升 3.X 不就好了
另外,表情插件哪里搞?
我就是过来试一下头像
可以 已经显示了
以前一直以为只有 windows 系统才能安装 Python...
备注:CentOS7 升级需要改两个文件,另外 firewall 的配置文件也要改
另:编译前请安装必要依赖
不错的补充,因为我在配置环境的时候已经安装了所需依赖包所以文中没有提依赖包的事。不过升级完 py ,pip 也需要重新安装下 好麻烦 ..