CentOS 7 Installation Python3

Source: Internet
Author: User

CentOS 7 installs Python 2 by default, and when you need to use Python 3, you can manually download the Python source code and compile the installation.

First, install the Python 31.1 installation Preparation
$ sudo mkdir/usr/local/--no-check-certificate https://www.python.org/ftp/python/3.6.0/ Python-3.6.0.tgz# Note: wget get HTTPS to add:--no-check--xzvf python-3.6. 0 . tgz # Unzip the package $ cd Python-3.6. 0 # go to unzip directory
1.2 Compiling the installation
$ sudo./configure--prefix=/usr/local/Python3 # Specifies the directory created by sudo make$ sudo make install
1.3 Configuration 1.3.12 versions co-exist

To create a soft link for python3:

sudo ln-s/usr/local/python3/bin/python3/usr/bin/python3

1.3.2 Modify the default to Python 3 so that you can use Python python 2 with the command python3 to use Python 3.

The /usr/bin backup that is in python

$ sudo mv python Python.bak
$ sudo ln-s/usr/local/python3/bin/python3/usr/bin/python

Then create a soft link to the Python3

This will replace the default Python version with Python 3.

Because Yum uses Python 2, it may not work correctly after replacing with Python 3, so modify the Yum configuration file

Change the python version specified in the first line to python2.7 ( #!/usr/bin/python instead #!/usr/bin/python2.7 )

$ sudo vi/usr/bin/yum

Second, install Pip

2.1 Yum Installation
-y install epel-release# installation python-y install python-pip# clear cache$ sudo yum clean all

2.2 Source Installation

This way seems to only install PIP2, want to install the Python 3 pip, you can use the following source code installation method.

--no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz9.0. 1 -C pip-9.0. 1     # Unzip files $ cd pip-9.0. 1  3  Installing $ python3 setup.py Install

To create a link:

$ sudo ln-s/usr/local/python3/bin/pip/usr/bin/pip3
2.3 Upgrading PIP
$ pip Install--upgrade pip


CentOS 7 Installation Python3

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.