Python-3.6.2 version upgrade installation under Linux

In this paper, under the Linux (CentOS) will be upgraded to version Python 3.6.2 Method

As we all know, in 2020 python 2.7 will no longer support the official version of python, so use the 3.x version of python is necessary, but the default python in linux installation is generally 2.6 and 2.7 versions, and if you use python in linux it is necessary to look to upgrade

Into the title

1. Check information system

[root@zstest1 ~]# cat /etc/redhat-release 
CentOS release 6.5 (Final)
[root@zstest1 ~]# uname -a
Linux zstest1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@zstest1 ~]# python -V
Python 2.6.6

My system is a software upgrade of CentOS6.5-x86_64 kernel 2.6.32, the current python version is 2.6.6

2. Download the Python-3.6.2 installed

1) Download the Python-3.6.2.tgz package

[root@zstest1 ~]# mkdir -p /server/tools/
[root@zstest1 tools]# cd /server/tools/
[root@zstest1 tools]# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

2) compile and install unzip

[root@zstest1 tools]# tar -xf Python-3.6.2.tgz
[root@zstest1 tools]# cd Python-3.6.2
[root@zstest1 Python-3.6.2]# ./configure
[root@zstest1 Python-3.6.2]# make
[root@zstest1 Python-3.6.2]# make install

# If the compiler errors, you need to check the make, gcc, etc. are installed

yum install make gcc gcc-c++ 

3) the installation is complete, you need to change the default python version

# Check the current default python2, the default position that comes with python in "/ usr / bin /" directory

[root@zstest1 Python-3.6.2]# ll /usr/bin/python*
-rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python
lrwxrwxrwx. 1 root root    6 3月  20 2016 /usr/bin/python2 -> python
-rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python2.6

# Check the newly installed python3, compiled and installed by default python position in "/ usr / local / bin /" directory

Copy the code
[root@zstest1 Python-3.6.2]# ll /usr/local/bin/python*
lrwxrwxrwx 1 root root       9 10月 31 16:48 /usr/local/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6
lrwxrwxrwx 1 root root      17 10月 31 16:48 /usr/local/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6m
-rwxr-xr-x 1 root root    3066 10月 31 16:48 /usr/local/bin/python3.6m-config
lrwxrwxrwx 1 root root      16 10月 31 16:48 /usr/local/bin/python3-config -> python3.6-config
Copy the code

# Modify the default python

# Delete the old python soft link to create a new python2 and soft connection python3

[root@zstest1 Python-3.6.2]# cd /usr/bin/
[root@zstest1 bin]# rm -f python2
[root@zstest1 bin]# mv python python2.6.ori
[root@zstest1 bin]# ln -s python2.6 python2
[root@zstest1 bin]# ln -s /usr/local/bin/python3 /usr/bin/python

4) python version of the Check for Modifications

[root@zstest1 bin]# python -V
Python 3.6.2
[root@zstest1 bin]# python2 -V
Python 2.6.6
[root@zstest1 bin]# python3 -V
Python 3.6.2

# You can find open by default python version is already 3.6.2, the version has been upgraded so far successfully python

3. Subsequent processing software problems

After the default version # python modified to 3.x, the system call will be problems for yum, so you need to modify the relevant configuration of yum

[root@zstest1 bin]# vim /usr/bin/yum

# Need to check the following configuration

#!/usr/bin/python2

# In this way, yum modified still can call python python2.6.6 of when using yum to install software not being given the

# These are the python version upgrade performed on CentOS6.5 system, CentOS7.2 above default python version is 2.7.5, you can use the same method to be modified, but the python link CentOS7.2 slightly different note

[root@centos72 ~]# ll /usr/bin/python*
lrwxrwxrwx. 1 root root    7 10月 26 2016 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root    9 10月 26 2016 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 11月 20 2015 /usr/bin/python2.7

# The other is, CentOS7.2 there is another file needs to be modified

[root@centos72 ~]# vim /usr/libexec/urlgrabber-ext-down

# Check that the following configuration:

#!/usr/bin/python2

======== completed, Oh Oh =========

Thanksgiving, mutual aid and sharing.

In this paper, under the Linux (CentOS) will be upgraded to version Python 3.6.2 Method

As we all know, in 2020 python 2.7 will no longer support the official version of python, so use the 3.x version of python is necessary, but the default python in linux installation is generally 2.6 and 2.7 versions, and if you use python in linux it is necessary to look to upgrade

Into the title

1. Check information system

[root@zstest1 ~]# cat /etc/redhat-release 
CentOS release 6.5 (Final)
[root@zstest1 ~]# uname -a
Linux zstest1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@zstest1 ~]# python -V
Python 2.6.6

My system is a software upgrade of CentOS6.5-x86_64 kernel 2.6.32, the current python version is 2.6.6

2. Download the Python-3.6.2 installed

1) Download the Python-3.6.2.tgz package

[root@zstest1 ~]# mkdir -p /server/tools/
[root@zstest1 tools]# cd /server/tools/
[root@zstest1 tools]# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

2) compile and install unzip

[root@zstest1 tools]# tar -xf Python-3.6.2.tgz
[root@zstest1 tools]# cd Python-3.6.2
[root@zstest1 Python-3.6.2]# ./configure
[root@zstest1 Python-3.6.2]# make
[root@zstest1 Python-3.6.2]# make install

# If the compiler errors, you need to check the make, gcc, etc. are installed

yum install make gcc gcc-c++ 

3) the installation is complete, you need to change the default python version

# Check the current default python2, the default position that comes with python in "/ usr / bin /" directory

[root@zstest1 Python-3.6.2]# ll /usr/bin/python*
-rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python
lrwxrwxrwx. 1 root root    6 3月  20 2016 /usr/bin/python2 -> python
-rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python2.6

# Check the newly installed python3, compiled and installed by default python position in "/ usr / local / bin /" directory

Copy the code
[root@zstest1 Python-3.6.2]# ll /usr/local/bin/python*
lrwxrwxrwx 1 root root       9 10月 31 16:48 /usr/local/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6
lrwxrwxrwx 1 root root      17 10月 31 16:48 /usr/local/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6m
-rwxr-xr-x 1 root root    3066 10月 31 16:48 /usr/local/bin/python3.6m-config
lrwxrwxrwx 1 root root      16 10月 31 16:48 /usr/local/bin/python3-config -> python3.6-config
Copy the code

# Modify the default python

# Delete the old python soft link to create a new python2 and soft connection python3

[root@zstest1 Python-3.6.2]# cd /usr/bin/
[root@zstest1 bin]# rm -f python2
[root@zstest1 bin]# mv python python2.6.ori
[root@zstest1 bin]# ln -s python2.6 python2
[root@zstest1 bin]# ln -s /usr/local/bin/python3 /usr/bin/python

4) python version of the Check for Modifications

[root@zstest1 bin]# python -V
Python 3.6.2
[root@zstest1 bin]# python2 -V
Python 2.6.6
[root@zstest1 bin]# python3 -V
Python 3.6.2

# You can find open by default python version is already 3.6.2, the version has been upgraded so far successfully python

3. Subsequent processing software problems

After the default version # python modified to 3.x, the system call will be problems for yum, so you need to modify the relevant configuration of yum

[root@zstest1 bin]# vim /usr/bin/yum

# Need to check the following configuration

#!/usr/bin/python2

# In this way, yum modified still can call python python2.6.6 of when using yum to install software not being given the

# These are the python version upgrade performed on CentOS6.5 system, CentOS7.2 above default python version is 2.7.5, you can use the same method to be modified, but the python link CentOS7.2 slightly different note

[root@centos72 ~]# ll /usr/bin/python*
lrwxrwxrwx. 1 root root    7 10月 26 2016 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root    9 10月 26 2016 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 11月 20 2015 /usr/bin/python2.7

# The other is, CentOS7.2 there is another file needs to be modified

[root@centos72 ~]# vim /usr/libexec/urlgrabber-ext-down

# Check that the following configuration:

#!/usr/bin/python2

======== completed, Oh Oh =========

Guess you like

Origin www.cnblogs.com/xzlive/p/11572765.html