Python3 installation of PIP3

Source: Internet
Author: User
Tags install openssl
This time to everyone to bring Python3 installation PIP3, Python3 installation of the notes of the PIP3, the following is the actual case, together to see.

Objective:

I currently use the server for the centos6.x system comes with a python version of 2.6.x, but now whether the study or use of Python,python3 are the first choice, then the problem comes. ---How to install the PYTHON3 environment, and how to install the corresponding PIP3 Python3? More crucially, there are some tools in our original system that need to be used in the python2.6 version, so Python3 and python2 coexist, PIP2 and PIP3 coexist. The following article is my personal practice. (Install PIP3 for python3)

The purpose of writing this is to help also meet the same problem of the comrades (the current online information is not easy to find, most of them have not been practice, the following is my experience, hundred hundred can be successful!! Go!! go!! )

First, install Python3

Installation python3.x here not much to repeat, so easzy!!

1. Download the Python3 installation package to the official website first

Official address---I downloaded the PYTHON-3.5.2.TAR.XZ

2. Upload the package to the server

3. Unzip

TAR-XF PYTHON-3.5.2.TAR.XZ

4. Compiling the installation

!!! Note ️ before compiling need to install some necessary dependencies, or when the error will have to recompile--(I eat this loss, we must pay attention to AO ...) )

Install the necessary dependencies (at least two of the following, I personally encountered the following two)

Yum Install Openssl-devel-yyum Install zlib-devel-y

Okay, now you can compile it with peace of mind:

CD python-3.5.2./configure--prefix=/opt/python  #安装目录可以自己定义无所谓. Makemake Install

After compiling, the Python folder will be generated under/opt/, which is the compiled Python-for the convenience of the small partners can define a soft connection as follows:

# ln-s/opt/python/bin/python3/usr/bin/python3

This allows direct consumption of Python3 as follows:

So far, our task of installing Python3 under Linux has been completed, and the following goes to the critical place to install the Python3 PIP3

Second, install PIP for python3.x

In fact, this is not difficult. Download a package and execute two commands.

1. First install the Setuptools

Small partners can be downloaded via the official module library: Download address

Here I will directly use the wget to the server download version 19.6 (small partners can try the new version of Austria. )

wget--no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5= C607DD118EAE682C44ED146367A17E26TAR-ZXVF SETUPTOOLS-19.6.TAR.GZCD Setuptools-19.6.tar.gzpython3 setup.py Buildpython3 setup.py Install

2. Then install the PIP directly and it's done.

Also download first and then execute the command to get it done!!

wget--no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5= 3A73C4188F8DBAD6A1E6F6D44D117EEBTAR-ZXVF pip-8.0.2.tar.gzcd pip-8.0.2python3 setup.py buildpython3 setup.py Install

After the installation is complete, let's look at what's in the Python bin directory.

Ha ha.. Through the above we have already installed PIP3 for Python3 ... (The small partners can also make a soft connection, to facilitate the practical Olympics.) )

Three, let's do a test.

1. First we enter the PYTHO3

[Root@centos3 bin]# Python3python 3.5.2 (default, Jul, 03:36:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linuxty  PE "help", "copyright", "credits" or "license" for more information.>>> import Pymysqltraceback (most recent call Last): File "<stdin>", line 1, in <module>importerror:no module named ' pymysql ' # #没有此模块奥 >>>

OK, let's install the newly installed PIP3 to try it out:

[Root@centos3 bin]#/opt/python/bin/pip3 install pymysqlcollecting pymysql downloading PYMYSQL-0.7.5-PY2.PY3-NONE-ANY.WHL (77kB) 100% |████████████████████████████████| 81kB 3.2kb/s Installing collected packages:pymysqlsuccessfully installed pymysql-0.7.5##### #安装完成

Installation is complete, it seems PIP3 itself no problem, we test whether the real to Python3 loaded this module it (it may be installed on the python2 on it ...-_-#)

[Root@centos3 bin]# Python3python 3.5.2 (default, Jul, 03:36:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linuxty PE "help", "copyright", "credits" or "license" for more information.>>> import pymysql>>>

hahaha OK. End!!

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

How does python achieve the Markov distance

Perfect solution python2.7 cannot use Pip

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.