Install Python3 on CentOS7

Source: Internet
Author: User

Install Python3 on CentOS7

Python2.7.5 is installed in CentOS7 by default. When you need to use python3, You can manually download the python source code and compile and install it.

  1. Download python (https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz)
  2. Decompress the downloaded package
  3. Sudo mkdir/usr/local/python3
    Enter the sudo./configure -- prefix =/usr/local/python3 directory.
  4. Sudo make
  5. Sudo make install
  6. In/usr/bin, there are python, python2, and python2.7 files pointing to the latter in sequence. We will back up python (sudo mv python. and then create the soft link of python3 (sudo ln-s/usr/local/python3/bin/python3/usr/bin/python ). In this way, the default python version is replaced with python3.
  7. Because yum uses python2, replacing it with python3 may not work properly. Therefore, modify the yum configuration file (sudo vi/usr/bin/yum ).
    Change the python version specified in the first line to python2.7 (#! /Usr/bin/python #! /Usr/bin/python2.7)

Note:
Another possibility is that yum cannot be used, that is, python, python2, and python2.7 files under/usr/bin are changed.
If you cannot use yum after modifying the default python version, you can only restore python. bak. Then, create a new soft link for python3, for example, name it python3.

Finally:
I have successfully installed python3 without any "NOTE". However, when installing software that requires python3 dependency, I am prompted to require python3 dependency and my python version is python2, I do not know how to solve this problem.

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.