Skip to content

Commit 691488e

Browse files
author
Kenneth Reitz
committed
distribute and pip
1 parent fe031c6 commit 691488e

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

docs/starting/install/linux.rst

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
Installing Python on Linux
22
==========================
33

4+
The latest version of Ubuntu, **comes with Python 2.7 out of the box**.
45

5-
The latest version of Ubuntu, **comes with Python 2.7 out of the box**. Python 3.2 can be installed and run with the following commands::
6+
Distribute & Pip
7+
----------------
68

7-
$ sudo apt-get install python3-minimal
8-
$ python3
9+
The most crucial third-party Python software of all is Distribute, which extends the packaging and installation facilities provided by the distutils in the standard library. Once you add Distribute to your Python system you can download and install any compliant Python software product with a single command. It also enables you to add this network installation capability to your own Python software with very little work.
910

10-
Older versions of Python aren't available from the official repository. However, if it's needed (for example to support legacy code), we can add an unsupported repository and install an older version of Python (2.5 in the example below)::
11+
To obtain the latest version of Distribute for Linux, run the python script available here:
12+
http://python-distribute.org/distribute_setup.py
1113

12-
$ sudo apt-get install python-software-properties
13-
$ sudo add-apt-repository ppa:fkrull/deadsnakes
14-
$ sudo apt-get update
15-
$ sudo apt-get install python2.5
14+
The new``easy_install`` command you have available is considered by many to be deprecated, so we will install its replacement: **pip**. Pip allows for uninstallation of packages, and is actively maintained, unlike easy_install.
1615

17-
Installing setuptools and pip
18-
-----------------------------
16+
To install pip, simply open a command prompt and run::
1917

20-
While Python has an extensive standard library, the set of packages available from the Internet is even more extensive. In order to install them easily, we'll install the ``distribute`` package and then ``pip``::
18+
$ easy_install pip
2119

22-
$ wget http://python-distribute.org/distribute_setup.py
23-
$ sudo python distribute_setup.py
24-
$ sudo easy_install pip
2520

26-
Now, most Python packages can be installed using the ``pip`` command. For example, if we wanted to install Django::
21+
Virtualenv
22+
----------
2723

28-
$ sudo pip install django
24+
After Distribute & Pip, the next development tool that you should install is `virtualenv <http://pypi.python.org/pypi/virtualenv/>`_. Use pip::
2925

30-
A full list of ``pip``'s capabilities is available by typing ``pip --help``.
26+
$ pip install virtualenv
27+
28+
The virtualenv kit provides the ability to create virtual Python environments that do not interfere with either each other, or the main Python installation. If you install virtualenv before you begin coding then you can get into the habit of using it to create completely clean Python environments for each project. This is particularly important for Web development, where each framework and application will have many dependencies.
29+
30+
To set up a new Python environment, change the working directory to where ever you want to store the environment, and run the virtualenv utility in your project's directory::
31+
32+
$ virtualenv --distribute venv
33+
34+
To use an environment, run ``source venv/bin/activate``. Your command prompt will change to show the active environment. Once you have finished working in the current virtual environment, run ``deactivate`` to restore your settings to normal.
35+
36+
Each new environment automatically includes a copy of ``pip``, so that you can setup the third-party libraries and tools that you want to use in that environment. Put your own code within a subdirectory of the environment, however you wish. When you no longer need a particular environment, simply copy your code out of it, and then delete the main directory for the environment.
37+
38+
39+
--------------------------------
40+
41+
This page is a remixed version of `another guide <http://www.stuartellis.eu/articles/python-development-windows/>`_, which is available under the same license.
3142

0 commit comments

Comments
 (0)