Python detailed installation pip tutorial

Source: Internet
Author: User
Tags install openssl virtualenv

First install Python

I have installed two versions:

Python-2.7.10.tgz

Python-3.5.1.tgz

First look at the Python version that comes with the system:

1 [email protected] src]# python-v 2 Python 2.6.6

To install the Python2.7 version:

[Email protected] src]# tar zxvf python-2.7.10.tgz [[email protected] src]# CD Python-2.7.10[[email protected] Python-2.7 .10]#./configure--prefix=/usr/local/python27[[email protected] python-2.7.10]# make && make install

Back up the original Python version:

[Email protected] python-2.7.10]# Mv/usr/bin/python/usr/bin/python_old

To establish a Python2.7 soft connection:

1 [email protected] python-2.7.10]# ln-s/usr/local/python27/bin/python/usr/bin/python 2 [email protected] python-2.7.10]# python-v 3 Python 2.7.10

To install the Python3.5 version:

12[[email protected] src]# CD Python-3.5.13[[email protected] python-3.5.1]#./configure--prefix=/usr/local/python34[[email protected] python-3.5.1]# make && make install5[[email protected] python-3.5.1]# ln-s/usr/local/python3/bin/python3/usr/ Bin/python36[[email protected] python-3.5.1]# python3-v7 Python 3.5.1

Start installing PIP

First download PIP:

1 [[email protected] src]# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5= 834B2904F92D46AAA333267FB1C922BB "--no-check-certificate

Unzip the installation:

12[[email protected] src]# CD pip-1.5.43[[email protected] pip-1.5.4]# Python setup.py install4Traceback (most recent):5   <  Module>6from    setuptools Import setup, find_packages7 Importerror:no module named Setuptools

See "Importerror:no module named Setuptools", missing Setuptools module

Download and install the Setuptools module:

[Email protected] src]# wget--no-check-certificate https://pypi.python.org/packages/source/s/setuptools/ setuptools-12.0.3.tar.gz#md5=f07e4b0f4c1c9368fcd980d888b29a65 [[email protected] src]# tar zxvf setuptools-12.0.3.tar.gz [[email protected] setuptools-12.0.3]# python setup.py build[[email protected] setuptools-12.0.3]# python setup.py install***z = ZipFile. ZipFile (zip_filename, Mode, compression=compression)  File "/usr/local/python27/lib/python2.7/zipfile.py", line  736, in __init__    "Compression requires the (missing) zlib module" Runtimeerror:compression requires the (missing) zlib Module

See the missing zlib module, workaround:

[email protected] setuptools-12.0.3]# Yum install zlib zlib-devel

Python2.7 and 3.5 will need to be recompiled after the installation is complete:

[Email protected] setuptools-12.0.3]# CD. /python-2.7.10[[email protected] python-2.7.10]#./configure--prefix=/usr/local/python27/[[email Protected] python-2.7.10]# make && make Install[[email protected] python-2.7.10]# Rm-rf/usr/bin/python[[email protected] P ython-2.7.10]# Rm-rf/usr/bin/python3[[email protected] python-2.7.10]# ln-s/usr/local/python27/bin/python/usr/bin/ Python[[email protected] python-2.7.10]# CD. /setuptools-12.0.3[[email protected] setuptools-12.0.3]# python setup.py buildrunning buildrunning build_py[[email Protected] setuptools-12.0.3]# python setup.py install***processing dependencies for setuptools==12.0.3finished Processing dependencies for setuptools==12.0.3

After the reinstallation, it succeeded! But now just put the setuptools installed, in the re-install PIP:

[[email protected] pip-1.5.4]# python setup.py install

Installed/usr/local/python27/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg
Processing dependencies for pip==1.5.4
Finished processing dependencies for pip==1.5.4

[[email protected] pip-1.5.4]# python-m pip Install a

/usr/bin/python:cannot Import name Httpshandler; ' Pip ' is a package and cannot be directly executed

According to the above prompt is also missing Httpshandler module, installation:

[email protected] ~]# Yum install OpenSSL openssl-devel-y

Then reinstall the Python and install the PIP when the installation is complete:

[ [email protected] ~]# Pythonpython 2.7.10 (default, APR, 11:43:29) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on  Linux2type "Help", "copyright", "credits" or "license" for more information.>>> import virtualenvtraceback (most Recent call last): File "<stdin>", line 1, in<Module>Importerror:no module named Virtualenv>>> exit () [[email protected] ~]# python-m pip install virtualenvdownl oading/unpacking virtualenv downloading VIRTUALENV-15.0.1-PY2.PY3-NONE-ANY.WHL (1.8MB): 1.8MB downloadedInstalling Collected packages:virtualenvsuccessfully installed virtualenvcleaning up ... [Email protected] ~]# Pythonpython 2.7.10 (default, APR, 11:43:29) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on Lin Ux2type "Help", "copyright", "credits" or "license" for more information.>>> import virtualenv>>>

~ok, it's been a success!

If the installation is not a problem is the best, so when installing the software, you must first install the dependency package!

Python detailed installation pip tutorial

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.