5032ed21667a589ba900f9ee6f020d1b687be343
[python-guide.git] / docs / starting / install / linux.rst
1 .. _install-linux:
2
3 Installing Python on Linux
4 ==========================
5
6 The latest version of Ubuntu, **comes with Python 2.7 out of the box**.
7
8 You do not need to install or configure anything else to use Python. Having
9 said that, I would strongly recommend that you install the tools and libraries
10 described in the next section before you start building Python applications
11 for real-world use. In particular, you should always install Distribute, as
12 it makes it much easier for you to use other third-party Python libraries.
13
14 Distribute & Pip
15 ----------------
16
17 The most crucial third-party Python software of all is Distribute, which
18 extends the packaging and installation facilities provided by the distutils
19 in the standard library. Once you add Distribute to your Python system you can
20 download and install any compliant Python software product with a single
21 command. It also enables you to add this network installation capability to
22 your own Python software with very little work.
23
24 To obtain the latest version of Distribute for Linux, run the python script
25 available here: `python-distribute <http://python-distribute.org/distribute_setup.py>`_
26
27 The new``easy_install`` command you have available is considered by many to be
28 deprecated, so we will install its replacement: **pip**. Pip allows for
29 uninstallation of packages, and is actively maintained, unlike easy_install.
30
31 To install pip, simply open a command prompt and run
32
33 .. code-block:: console
34
35     $ easy_install pip
36
37
38 Virtualenv
39 ----------
40
41 After Distribute & Pip, the next development tool that you should install is
42 `virtualenv <http://pypi.python.org/pypi/virtualenv/>`_. Use pip
43
44 .. code-block:: console
45
46     $ pip install virtualenv
47
48 The virtualenv kit provides the ability to create virtual Python environments
49 that do not interfere with either each other, or the main Python installation.
50 If you install virtualenv before you begin coding then you can get into the
51 habit of using it to create completely clean Python environments for each
52 project. This is particularly important for Web development, where each
53 framework and application will have many dependencies.
54
55 To set up a new Python environment, change the working directory to where ever
56 you want to store the environment, and run the virtualenv utility in your
57 project's directory
58
59 .. code-block:: console
60
61     $ virtualenv venv
62
63 To use an environment, run ``source venv/bin/activate``. Your command prompt
64 will change to show the active environment. Once you have finished working in
65 the current virtual environment, run ``deactivate`` to restore your settings
66 to normal.
67
68 Each new environment automatically includes a copy of ``pip``, so that you can
69 setup the third-party libraries and tools that you want to use in that
70 environment. Put your own code within a subdirectory of the environment,
71 however you wish. When you no longer need a particular environment, simply
72 copy your code out of it, and then delete the main directory for the environment.
73
74
75 --------------------------------
76
77 This page is a remixed version of `another guide <http://www.stuartellis.eu/articles/python-development-windows/>`_,
78 which is available under the same license.
79