CentOS7use the python2.7.5 as default, you should pay acctention to two thing when upgrading the python to 3.5.2
- update the python link in the default sysytem
- fix the yum
A. install the python 3.5.2
1 2 |
# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz # tar -zxf Python-3.5.2.tgz |
B. install the python
1 2 3 4 |
# cd Python-3.5.2/ # ./configure # make # make install |
C. you will see this as below
1 2 3 4 5 |
# /usr/local/bin/python3.5 Python 3.5.2 (default, Jul 24 2016, 14:46:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> |
D. update the python link in the default sysytem
move and keep the old one for yum
1 |
mv /usr/bin/python /usr/bin/python2.7.5 |
make link to the system default python path
1 |
# ln -s /usr/local/bin/python3.5 /usr/bin/python |
you will see this below if success change defaule python to 3.5.2
1 2 3 4 5 |
[root@localhost ~]# python Python 3.5.2 (default, Jul 24 2016, 14:46:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> |
E. you will find that yum is broken
1 2 3 4 5 |
[root@localhost ~]# yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax |
you can fix it by follow this:
vim /usr/bin/yum
change:
1 |
#!/usr/bin/python |
to
1 |
#!/usr/bin/python2.7.5 |
F. All done
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@localhost ~]# yum Loaded plugins: fastestmirror, langpacks You need to give some command Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data deplist List a package‘s dependencies <strong> ... ...</strong> |
未经允许不得转载:VPS啦 » upgrade you python to 3.5.2 on CentOS 7 and fix the yum