Install Python3.5 on Centos7

Source: Internet
Author: User

Install Python3.5 on Centos7
Centos7 is installed with python2.7.5 by default. For example, yum uses python2.7.51 to download the package of python3.5.

Https://www.python.org/downloads/release/python-351/ at python Official Website
Download the tgz package. In fact, either of the following two packages can be used.
Python-3.5.1.tgz (this is not compiled, can not be decompressed directly use)
Python-3.5.1.tar.xz (this is pthon source code)

2-decompress the file
tar -xf Python-3.5.1.tgz 
3-decompress the package and enter the Python-3.5.1 directory.
cd Python-3.5.1
4-start installation and use the compilation method for Installation

There is a README file in the python Directory, which describes how to install python. However, we need to specify the installation directory.

mkdir /usr/python3.5./configure --prefix=/usr/python3.5makemake install

Note: After the/configure command is executed, create a file creating Makefile for the following make command to install the program in the specified directory after running make install.

5-use Python 3.5.1 by default

Python, python2, and python2.7 files in/usr/bin point to the latter in sequence.

       cd /usr/bin       mv python python.bak       ln -s /usr/python3.5/bin/python3 /usr/bin/python

Note that after compilation and installation, a python3 connection is automatically generated under/usr/python3.5/bin, which points to python3.5 in the bin directory.

6-Because yum uses python2, replacing it with python3 may not work properly. continue to use this python2.7.5

Therefore, modify the yum configuration file (sudo vi/usr/bin/yum ). #! /Usr/bin/python #! /Usr/bin/python2.7 save and exit.

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.