[ SEA-GHOST MINI SHELL]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>2. Using Python on Unix platforms — Python 2.7.5 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.7.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 2.7.5 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="Python 2.7.5 documentation" href="../index.html" />
<link rel="up" title="Python Setup and Usage" href="index.html" />
<link rel="next" title="3. Using Python on Windows" href="windows.html" />
<link rel="prev" title="1. Command line and environment" href="cmdline.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="windows.html" title="3. Using Python on Windows"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="http://www.python.org/">Python</a> »</li>
<li>
<a href="../index.html">Python 2.7.5 documentation</a> »
</li>
<li><a href="index.html" accesskey="U">Python Setup and Usage</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="using-python-on-unix-platforms">
<span id="using-on-unix"></span><h1>2. Using Python on Unix platforms<a class="headerlink" href="#using-python-on-unix-platforms" title="Permalink to this headline">¶</a></h1>
<div class="section" id="getting-and-installing-the-latest-version-of-python">
<h2>2.1. Getting and installing the latest version of Python<a class="headerlink" href="#getting-and-installing-the-latest-version-of-python" title="Permalink to this headline">¶</a></h2>
<div class="section" id="on-linux">
<h3>2.1.1. On Linux<a class="headerlink" href="#on-linux" title="Permalink to this headline">¶</a></h3>
<p>Python comes preinstalled on most Linux distributions, and is available as a
package on all others. However there are certain features you might want to use
that are not available on your distro’s package. You can easily compile the
latest version of Python from source.</p>
<p>In the event that Python doesn’t come preinstalled and isn’t in the repositories as
well, you can easily make packages for your own distro. Have a look at the
following links:</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference external" href="http://www.debian.org/doc/manuals/maint-guide/first.en.html">http://www.debian.org/doc/manuals/maint-guide/first.en.html</a></dt>
<dd>for Debian users</dd>
<dt><a class="reference external" href="http://en.opensuse.org/Portal:Packaging">http://en.opensuse.org/Portal:Packaging</a></dt>
<dd>for OpenSuse users</dd>
<dt><a class="reference external" href="http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html">http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html</a></dt>
<dd>for Fedora users</dd>
<dt><a class="reference external" href="http://www.slackbook.org/html/package-management-making-packages.html">http://www.slackbook.org/html/package-management-making-packages.html</a></dt>
<dd>for Slackware users</dd>
</dl>
</div>
</div>
<div class="section" id="on-freebsd-and-openbsd">
<h3>2.1.2. On FreeBSD and OpenBSD<a class="headerlink" href="#on-freebsd-and-openbsd" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">FreeBSD users, to add the package use:</p>
<div class="highlight-sh"><div class="highlight"><pre>pkg_add -r python
</pre></div>
</div>
</li>
<li><p class="first">OpenBSD users use:</p>
<div class="highlight-sh"><div class="highlight"><pre>pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz
</pre></div>
</div>
<p>For example i386 users get the 2.5.1 version of Python using:</p>
<div class="highlight-sh"><div class="highlight"><pre>pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="on-opensolaris">
<h3>2.1.3. On OpenSolaris<a class="headerlink" href="#on-opensolaris" title="Permalink to this headline">¶</a></h3>
<p>To install the newest Python versions on OpenSolaris, install <a class="reference external" href="http://www.blastwave.org/howto.html">blastwave</a> and type <tt class="docutils literal"><span class="pre">pkg_get</span> <span class="pre">-i</span> <span class="pre">python</span></tt> at the
prompt.</p>
</div>
</div>
<div class="section" id="building-python">
<h2>2.2. Building Python<a class="headerlink" href="#building-python" title="Permalink to this headline">¶</a></h2>
<p>If you want to compile CPython yourself, first thing you should do is get the
<a class="reference external" href="http://python.org/download/source/">source</a>. You can download either the
latest release’s source or just grab a fresh <a class="reference external" href="http://docs.python.org/devguide/setup#getting-the-source-code">clone</a>. (If you want
to contribute patches, you will need a clone.)</p>
<p>The build process consists in the usual</p>
<div class="highlight-sh"><div class="highlight"><pre>./configure
make
make install
</pre></div>
</div>
<p>invocations. Configuration options and caveats for specific Unix platforms are
extensively documented in the <a class="reference external" href="http://hg.python.org/cpython/file/2.7/README">README</a> file in the root of the Python
source tree.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last"><tt class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></tt> can overwrite or masquerade the <tt class="file docutils literal"><span class="pre">python</span></tt> binary.
<tt class="docutils literal"><span class="pre">make</span> <span class="pre">altinstall</span></tt> is therefore recommended instead of <tt class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></tt>
since it only installs <tt class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python</span><em><span class="pre">version</span></em></tt>.</p>
</div>
</div>
<div class="section" id="python-related-paths-and-files">
<h2>2.3. Python-related paths and files<a class="headerlink" href="#python-related-paths-and-files" title="Permalink to this headline">¶</a></h2>
<p>These are subject to difference depending on local installation conventions;
<span class="target" id="index-0"></span><tt class="xref std std-envvar docutils literal"><span class="pre">prefix</span></tt> (<tt class="docutils literal"><span class="pre">${prefix}</span></tt>) and <span class="target" id="index-1"></span><tt class="xref std std-envvar docutils literal"><span class="pre">exec_prefix</span></tt> (<tt class="docutils literal"><span class="pre">${exec_prefix}</span></tt>)
are installation-dependent and should be interpreted as for GNU software; they
may be the same.</p>
<p>For example, on most Linux systems, the default for both is <tt class="file docutils literal"><span class="pre">/usr</span></tt>.</p>
<table border="1" class="docutils">
<colgroup>
<col width="53%" />
<col width="47%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">File/directory</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><tt class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python</span></tt></td>
<td>Recommended location of the interpreter.</td>
</tr>
<tr class="row-odd"><td><tt class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></tt>,
<tt class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></tt></td>
<td>Recommended locations of the directories
containing the standard modules.</td>
</tr>
<tr class="row-even"><td><tt class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></tt>,
<tt class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></tt></td>
<td>Recommended locations of the directories
containing the include files needed for
developing Python extensions and
embedding the interpreter.</td>
</tr>
<tr class="row-odd"><td><tt class="file docutils literal"><span class="pre">~/.pythonrc.py</span></tt></td>
<td>User-specific initialization file loaded
by the user module; not used by default
or by most applications.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="miscellaneous">
<h2>2.4. Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h2>
<p>To easily use Python scripts on Unix, you need to make them executable,
e.g. with</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>chmod +x script
</pre></div>
</div>
<p>and put an appropriate Shebang line at the top of the script. A good choice is
usually</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="c">#!/usr/bin/env python</span>
</pre></div>
</div>
<p>which searches for the Python interpreter in the whole <span class="target" id="index-2"></span><tt class="xref std std-envvar docutils literal"><span class="pre">PATH</span></tt>. However,
some Unices may not have the <strong class="program">env</strong> command, so you may need to hardcode
<tt class="docutils literal"><span class="pre">/usr/bin/python</span></tt> as the interpreter path.</p>
<p>To use shell commands in your Python scripts, look at the <a class="reference internal" href="../library/subprocess.html#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> module.</p>
</div>
<div class="section" id="editors">
<h2>2.5. Editors<a class="headerlink" href="#editors" title="Permalink to this headline">¶</a></h2>
<p>Vim and Emacs are excellent editors which support Python very well. For more
information on how to code in Python in these editors, look at:</p>
<ul class="simple">
<li><a class="reference external" href="http://www.vim.org/scripts/script.php?script_id=790">http://www.vim.org/scripts/script.php?script_id=790</a></li>
<li><a class="reference external" href="http://sourceforge.net/projects/python-mode">http://sourceforge.net/projects/python-mode</a></li>
</ul>
<p>Geany is an excellent IDE with support for a lot of languages. For more
information, read: <a class="reference external" href="http://www.geany.org/">http://www.geany.org/</a></p>
<p>Komodo edit is another extremely good IDE. It also has support for a lot of
languages. For more information, read:
<a class="reference external" href="http://www.activestate.com/store/productdetail.aspx?prdGuid=20f4ed15-6684-4118-a78b-d37ff4058c5f">http://www.activestate.com/store/productdetail.aspx?prdGuid=20f4ed15-6684-4118-a78b-d37ff4058c5f</a></p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../contents.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">2. Using Python on Unix platforms</a><ul>
<li><a class="reference internal" href="#getting-and-installing-the-latest-version-of-python">2.1. Getting and installing the latest version of Python</a><ul>
<li><a class="reference internal" href="#on-linux">2.1.1. On Linux</a></li>
<li><a class="reference internal" href="#on-freebsd-and-openbsd">2.1.2. On FreeBSD and OpenBSD</a></li>
<li><a class="reference internal" href="#on-opensolaris">2.1.3. On OpenSolaris</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-python">2.2. Building Python</a></li>
<li><a class="reference internal" href="#python-related-paths-and-files">2.3. Python-related paths and files</a></li>
<li><a class="reference internal" href="#miscellaneous">2.4. Miscellaneous</a></li>
<li><a class="reference internal" href="#editors">2.5. Editors</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="cmdline.html"
title="previous chapter">1. Command line and environment</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="windows.html"
title="next chapter">3. Using Python on Windows</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li><a href="../_sources/using/unix.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="windows.html" title="3. Using Python on Windows"
>next</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
>previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="http://www.python.org/">Python</a> »</li>
<li>
<a href="../index.html">Python 2.7.5 documentation</a> »
</li>
<li><a href="index.html" >Python Setup and Usage</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation.
<br />
The Python Software Foundation is a non-profit corporation.
<a href="http://www.python.org/psf/donations/">Please donate.</a>
<br />
Last updated on Oct 13, 2020.
<a href="../bugs.html">Found a bug</a>?
<br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
SEA-GHOST - SHELL CODING BY SEA-GHOST