Linux under upgrade Python to 3.5.2 version

Source: Internet
Author: User

Original source: https://www.cnblogs.com/tssc/p/7762998.html

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 03:15:09 UTC 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

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

2) Unzip the build installation

[Email protected] tools]# 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.

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  2 root root 9032 November 2013/USR/BIN/PYTHONLRWXRWXRW X. 1 root root    6 March  2016/usr/bin/python2-python-rwxr-xr-x  2 root root 9032 November 2013/usr/bin/pyth on2.6

# Check for newly installed Python3

[[email protected] python-3.5.2]# ll/usr/local/bin/python*lrwxrwxrwx 1 root root       9 October 16:48/usr/local/bin/pytho  N3-Python3.5-rwxr-xr-x 2 root root 9630001 October 16:48/usr/local/bin/python3.5lrwxrwxrwx 1 root root      17 October 31 16:48/usr/local/bin/python3.5-config-Python3.5m-config-rwxr-xr-x 2 root root 9630001 October 16:48/usr/local/bin/p  Ython3.5m-rwxr-xr-x 1 root root    3066 October 16:48/usr/local/bin/python3.5m-configlrwxrwxrwx 1 root root      16 October 31 16:48/usr/local/bin/python3-config-Python3.5-config

# Modify the default Python

[[email protected] python-3.5.2]# cd/usr/bin/[[email protected] bin]# rm-f python2[[email protected] bin]# mv Python PYT Hon2.6.ori[[email protected] bin]# ln-s python2.6 python2[[email protected] bin]# ln-s/usr/local/bin/python3/usr/bin/p Ython

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

4) Check the modified Python version

[[email protected] bin]# Python-vpython 3.5.2[[email protected] bin]# Python2-vpython 2.6.6[[email protected] bin]# Pyth On3-vpython 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*lrwxrwxrwx. 1 root root    7 October 2016/usr/bin/python-python2lrwxrwxrwx. 1 root root    9 October 2016/usr/bin/python2-> ; Python2.7-rwxr-xr-x. 1 root root 7136 November 2015/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

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.