Install Python packages under Linux (Pip, Nose, virtualenv, distribute)

Source: Internet
Author: User
Tags virtualenv

Beginners have just begun to learn python, now learning "stupid methodology python" ing~

There are several packages that need to be installed in learning Exercise 46 o'clock: Pip, Nose, virtualenv, distribute! Here's how to install Python packages under Linux:

1, first we just what is PIP?

On the Python website of Pip we can see that Pip is "A tool for installing and managing Python packages.", which means that Pip is a Python software Installation tool, Here's how to use the PIP:

Installation package:

Pip Install Somepackage

To view which files are installed when the package is installed:

Pip Show--files Somepackage

See which packages have updates:

Pip Show--files Somepackage

Update a software:

Pip Install--upgrade somepackage

Uninstalling the Software:

Pip Uninstall Somepackage

So, with Pip we can automatically install other packages, such as the nose, virtualenv, distribute we need.

2. Install the PIP package

Download the PIP package (pip-1.4.1.tar.gz) on the PIP Python page above, use "TAR-XVF pip-1.4.1.tar.gz" to extract the CD into the folder, and install the software using the "Python setup.py Install" command. (If you don't want to use PIP to install the package, you can use this method to download and unzip the installation using the Python setup.py install!) )

    1. [Email protected]:/tmp/pip-1.4.1$ tar-xvf pip-1.4.1.tar.gz
    2. [Email protected]:/tmp/pip-1.4.1$ cd PIP-1.4.1/
    3. [email protected]:/tmp/pip-1.4.1$ sudo python setup.py install
    4. [sudo] password for Dslab:
    5. Traceback (most recent):
    6. File "setup.py", line 5, <module>
    7. From Setuptools import Setup, find_packages
    8. Importerror:no module named Setuptools


When you install PIP, you are prompted to use the Setuptools module in setup.py, but the Setuptools software package is not installed on the computer, so we need to download and install the setuptools!

3. Installing the Setuptools Package

You can open Setuptools's Python website first to see how the Setuptools package installs:

> wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py> python ez_setup.py--user

You can also download the Setuptools package after installation:

(1) Download Setuptools package
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2) Unzip the Setuptools bag
# tar ZXVF setuptools-2.0.tar.gz
# CD setuptools-2.0
(3) Compiling setuptools
# python setup.py Build
(4) Start to perform Setuptools installation
# python setup.py Install

4. Install PIP again and install additional packages using PIP

Now that Setuptools is installed, we go into the pip-1.4.1 directory again and install the PIP using the "Python setup.py Install" command:

[Email protected]:/tmp$ cd PIP-1.4.1/
[email protected]:/tmp/pip-1.4.1$ sudo python setup.py install
...

After the PIP is installed, we can install the other packages directly using PIP:

sudo pip install nose

sudo pip install virtualenv

sudo pip install distribute

However, if you use Pip to install the software at this point, the following error occurs:

    1. [Email protected]:/tmp/pip-1.4.1$ sudo pip install nose
    2. Sudo:pip:command not found


Note that the above installation PIP still has a problem, I found the solution on the Internet:

[Email protected]:/tmp/pip-1.4.1$ CD.
[Email protected]:/tmp$ sudo easy_install pip-1.4.1/
...

Note: In fact I do not know why the use of "sudo python setup.py install" installation will be wrong, I installed on my desktop very smooth, but in the Notebook mountain installation is a problem! Using the "sudo easy_install pip-1.4.1/" installation is normal!

===================================

Resources:

"1" Official documentation is always the best, so if you want to install any software first open the official website to see the best option (the Python website that has added several packages above)

"2" Http://stackoverflow.com/questions/9780717/bash-pip-command-not-found

"3" http://blog.csdn.net/my2010sam/article/details/18315687

Install Python packages under Linux (Pip, Nose, virtualenv, distribute)

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.