Issue #7117: Update float formatting testcases to match those in py3k.
[python.git] / Doc / using / unix.rst
blob3d562a8b09f86825c04e256a228c5841518e98b0
1 .. highlightlang:: none
3 .. _using-on-unix:
5 ********************************
6  Using Python on Unix platforms
7 ********************************
9 .. sectionauthor:: Shriphani Palakodety
12 Getting and installing the latest version of Python
13 ===================================================
15 On Linux
16 --------
18 Python comes preinstalled on most Linux distributions, and is available as a
19 package on all others.  However there are certain features you might want to use
20 that are not available on your distro's package.  You can easily compile the
21 latest version of Python from source.
23 In the event that Python doesn't come preinstalled and isn't in the repositories as
24 well, you can easily make packages for your own distro.  Have a look at the
25 following links:
27 .. seealso::
29    http://www.linux.com/articles/60383
30       for Debian users
31    http://linuxmafia.com/pub/linux/suse-linux-internals/chapter35.html
32       for OpenSuse users
33    http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-creating-rpms.html
34       for Fedora users
35    http://www.slackbook.org/html/package-management-making-packages.html
36       for Slackware users
39 On FreeBSD and OpenBSD
40 ----------------------
42 * FreeBSD users, to add the package use::
44      pkg_add -r python
46 * OpenBSD users use::
48      pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz
50   For example i386 users get the 2.5.1 version of Python using::
52      pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
55 On OpenSolaris
56 --------------
58 To install the newest Python versions on OpenSolaris, install blastwave
59 (http://www.blastwave.org/howto.html) and type "pkg_get -i python" at the
60 prompt.
63 Building Python
64 ===============
66 If you want to compile CPython yourself, first thing you should do is get the
67 `source <http://python.org/download/source/>`_. You can download either the
68 latest release's source or just grab a fresh `checkout
69 <http://www.python.org/dev/faq/#how-do-i-get-a-checkout-of-the-repository-read-only-and-read-write>`_.
71 The build process consists the usual ::
73    ./configure
74    make
75    make install
77 invocations. Configuration options and caveats for specific Unix platforms are
78 extensively documented in the :file:`README` file in the root of the Python
79 source tree.
81 .. warning::
83    ``make install`` can overwrite or masquerade the :file:`python` binary.
84    ``make altinstall`` is therefore recommended instead of ``make install``
85    since it only installs :file:`{exec_prefix}/bin/python{version}`.
88 Python-related paths and files
89 ==============================
91 These are subject to difference depending on local installation conventions;
92 :envvar:`prefix` (``${prefix}``) and :envvar:`exec_prefix` (``${exec_prefix}``)
93 are installation-dependent and should be interpreted as for GNU software; they
94 may be the same.
96 For example, on most Linux systems, the default for both is :file:`/usr`.
98 +-----------------------------------------------+------------------------------------------+
99 | File/directory                                | Meaning                                  |
100 +===============================================+==========================================+
101 | :file:`{exec_prefix}/bin/python`              | Recommended location of the interpreter. |
102 +-----------------------------------------------+------------------------------------------+
103 | :file:`{prefix}/lib/python{version}`,         | Recommended locations of the directories |
104 | :file:`{exec_prefix}/lib/python{version}`     | containing the standard modules.         |
105 +-----------------------------------------------+------------------------------------------+
106 | :file:`{prefix}/include/python{version}`,     | Recommended locations of the directories |
107 | :file:`{exec_prefix}/include/python{version}` | containing the include files needed for  |
108 |                                               | developing Python extensions and         |
109 |                                               | embedding the interpreter.               |
110 +-----------------------------------------------+------------------------------------------+
111 | :file:`~/.pythonrc.py`                        | User-specific initialization file loaded |
112 |                                               | by the user module; not used by default  |
113 |                                               | or by most applications.                 |
114 +-----------------------------------------------+------------------------------------------+
117 Miscellaneous
118 =============
120 To easily use Python scripts on Unix, you need to make them executable,
121 e.g. with ::
123    $ chmod +x script
125 and put an appropriate Shebang line at the top of the script.  A good choice is
126 usually ::
128    #!/usr/bin/env python
130 which searches for the Python interpreter in the whole :envvar:`PATH`.  However,
131 some Unices may not have the :program:`env` command, so you may need to hardcode
132 ``/usr/bin/python`` as the interpreter path.
134 To use shell commands in your python scripts, look at the :mod:`subprocess` module.
137 Editors
138 =======
140 Vim and Emacs are excellent editors which support Python very well.  For more
141 information on how to code in python in these editors, look at:
143 * http://www.vim.org/scripts/script.php?script_id=790
144 * http://sourceforge.net/projects/python-mode
146 Geany is an excellent IDE with support for a lot of languages. For more
147 information, read: http://geany.uvena.de/
149 Komodo edit is another extremely good IDE.  It also has support for a lot of
150 languages. For more information, read:
151 http://www.activestate.com/store/productdetail.aspx?prdGuid=20f4ed15-6684-4118-a78b-d37ff4058c5f