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