Latest:

upgrade you python to 3.5.2 on CentOS 7 and fix the yum

Uncategorized willing 502Views 0 comment

CentOS7use the python2.7.5 as default, you should pay acctention to two thing when upgrading the  python to 3.5.2

  1. update the python link in the default sysytem
  2. fix the yum

 

A. install the  python 3.5.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

# cd Python-3.5.2/
# ./configure 
# make
# make install

C.  you will see this as below

# /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

 mv /usr/bin/python /usr/bin/python2.7.5

make link to the system default python path

# ln -s /usr/local/bin/python3.5 /usr/bin/python

you will see this below if success change defaule python to 3.5.2

[[email protected] ~]# 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

[[email protected] ~]# 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:

#!/usr/bin/python

to

#!/usr/bin/python2.7.5

F. All done

[[email protected] ~]# 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

... ...

 

Keep link to this when copy:VPS List Agent » upgrade you python to 3.5.2 on CentOS 7 and fix the yum

You must Login to submit a comment