Installing Python3 and PIP2 in CentOs

Source: Internet
Author: User

Today, the installation of CentOs 7 in the virtual machine, after the installation is complete found that its own python environment only Python 2.7, but also need to install Python 3, this is not as friendly as Ubuntu, and hope to bring Python 3 in the future.
PIP2 installed in the last
First go to the official website to download Python 3 source package Bai. Manual Skip ...
After downloading, unzip it first:

Note All of the following commands are in the root environment because some permissions issues

TAR-XZVF python-3.6.5.tgz
XZVF self-input tar--help view
Enter Python-3.6.5:

CD Python-3.6.5
./configure--prefix=/usr/local/python3.6

Make sure the installation directory can be entered./configure--help view options to start compiling the installation

Make && make install

Forget to say one thing, compile requires gcc so, smart you must have already installed

Yum Install GCC
At the end of the compilation installation will be reported errors, meaning is missing a module, presumably, forget ...

Zipimport. Zipimporterror:can ' t decompress data;zlib not avaliable
Make: * * * [install] Error 1
This is because Python needs to unzip something and need this module, so go ahead and install it:

Yum Install Zlib-devel
After the installation is complete, open Python 3 will find that the upper and lower keys can not be used, which is embarrassing, the original is missing a module to escape, these are historical reasons. If you have any interest, you can search for it after a try. The solution is to install:

Yum Install Readline-devel
Once again make && makes install, careful you will find some problems during making && do install, I still do not.

This is missing some modules, but you do not have to use it, for the future, or install it:
Yum Install Bzip2-devel
Yum Install Sqlite-devel
Yum Install Gdbm-devel
Yum Install Tk-devel

The lack of any control of what appears on your computer Baidu can be found in a bit

Then go ahead and make && do install, not surprisingly this time will be done! But there is a big problem, you enter Python3 probably will not enter the interpreter, because it does not enter into the environment variable. To create a soft link:

Bring Python3 and pip3 into effect

Ln-s/usr/local/python3/bin/python3/usr/bin/python3
Ln-s/USR/LOCAL/PYTHON3/BIN/PIP3/USR/BIN/PIP3

It's strange why local will change color.

All right, here we go.
Incidentally, the Python 2.7 in CentOs does not need to be installed on its own.
There's no pip in the official Yum store, so you can install EPEL, and I've been a little confused about this stuff at first, what's this?

The Enterprise Linux add-on package (hereinafter referred to as EPEL) is a Fedora special interest group that creates, maintains, and manages a high-quality add-on package set for Enterprise Linux, including but not limited to Red Hat Enterprise Linux (RHEL), CentOS, Sc Ientific Linux (SL), Oracle Linux (OL).

White is another warehouse, there are a lot of software. According to the instructions of this official tutorial:

This is CentOs 7.

Yum Install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
After a yes, run:

Yum Install Python-pip
The PIP2 can then be used normally.
Specific to/usr/bin/under LS pip or ls python view.

Installing Python3 and PIP2 in CentOs

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.