Linux under upgrade Python to 3.5.2 version

Source: Internet
Author: User

This article mainly introduces the method of upgrading Python version to 3.5.2 under Linux (CentOS)

Known In 2020 Python will no longer support the 2.7 version of Python, so it is necessary to use the 3.x version of Python, but the default installation of Python in Linux is typically version 2.6 and 2.7, and if you use Python under Linux it is necessary to upgrade

Go to the Chase

1. Check the confirmation system for information

 [[email protected] ~]# cat /etc/redhat- release CentOS release  6.5   (Final) [[email protected] ~]#  uname -alinux 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[[ email protected] ~]# python -vpython 2.6.6   

My software upgrade system is centos6.5-x86_64, kernel 2.6.32, the current Python version number is 2.6.6

2. Download and install Python-3.5.2

1) Download Python-3.5.2.tgz package

mkdir -p/server/tools/tools]# cd/server/tools/[[email protected] Toolswget HTTPS://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

2) Unzip the build installation

tar -xf python-3.5. 2 . Tgz[[email protected] tools]# CD Python-3.5. 2 [email protected] Python-3.5. 2] #./Configure[[email protected] Python-3.5. 2  Make [email protected] Python-3.5. 2  Make Install

# if the compilation error, you need to check whether MAKE,GCC and so on is installed.

Yum Install  Make GCC GCC

3) The default Python version needs to be changed when the installation is complete

# Check the current default Python2

[Email protected] python-3.5. 2] # ll/usr/bin/python*-rwxr-xr-x  29032 /usr/bin/1 Root root    6 March   /usr/bin/python2, python-rwxr-xr-x  29032 /usr/bin/python2. 6

# Check for newly installed Python3

[Email protected] python-3.5.2]# ll/usr/local/bin/python*lrwxrwxrwx1Root root9October to  -: -/usr/local/bin/python3, Python3.5-rwxr-xr-x2Root root9630001October to  -: -/usr/local/bin/python3.5lrwxrwxrwx1Root root -October to  -: -/usr/local/bin/python3.5-config-python3.5m-Config-rwxr-xr-x2Root root9630001October to  -: -/usr/local/bin/Python3.5m-rwxr-xr-x1Root root3066October to  -: -/usr/local/bin/python3.5m-configlrwxrwxrwx1Root root -October to  -: -/usr/local/bin/python3-config, Python3.5-config

# Modify the default Python

[Email protected] python-3.5. 2] # cd/usr/bin/rm -mv python python2. 6  Ln -S python2. 6  Ln -s/usr/local/bin/python3/usr/bin/python

# delete old Python soft connection, create new Python2 and Python3 soft connection

4) Check the modified Python version

[email protected] bin]# python-3.5. 2  -2.6. 6  -3.5. 2

# as you can see, the Python version opened by default is already 3.5.2, and this Python version has been upgraded successfully

3. Follow-up software problem handling

# after the default version of Python has been modified to 3.x, the system will have problems with Yum's call, so you need to modify the configuration of the following Yum

[Email protected] bin]# vim/usr/bin/Yum

# need to check to confirm the following configuration

#!/usr/bin/python2

# In this way, the modified Yum can still call python2.6.6 python, and will not error when installing the software with Yum

# above is a Python version upgrade on the CentOS6.5 system, CentOS7.2 the default Python version above is 2.7.5, can be modified using the same method, but CentOS7.2 python links are slightly different, you need to pay attention to

[Email protected] ~]# ll/usr/bin/python*1 root root    7 /usr/ Bin/python-1 root root    9 /usr/bin/python2 Python2. 7 1 7136  -  /usr/bin/python2. 7

# Plus, CentOS7.2, there's another file that needs to be modified.

[Email protected] ~]# Vim/usr/libexec/urlgrabber-ext-down

# confirm the following configuration:

#!/usr/bin/python2

Finished, hehe.

Linux under upgrade Python to 3.5.2 version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.