mirror of
https://github.com/kennethreitz-archive/conductofcode.git
synced 2026-06-05 23:30:19 +00:00
275 lines
14 KiB
HTML
275 lines
14 KiB
HTML
|
|
<!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>Properly Installing Python — pythonguide 0.0.1 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/flasky.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '0.0.1',
|
|
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>
|
|
<link rel="top" title="pythonguide 0.0.1 documentation" href="../index.html" />
|
|
<link rel="next" title="Your Development Environment" href="dev-env.html" />
|
|
<link rel="prev" title="Picking an Interpreter" href="which-python.html" />
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
|
|
|
|
</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="dev-env.html" title="Your Development Environment"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="which-python.html" title="Picking an Interpreter"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">pythonguide 0.0.1 documentation</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="properly-installing-python">
|
|
<h1>Properly Installing Python<a class="headerlink" href="#properly-installing-python" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="mac-os-x">
|
|
<h2>Mac OS X<a class="headerlink" href="#mac-os-x" title="Permalink to this headline">¶</a></h2>
|
|
<p><em>Or, “Installing Python 2.7 via Homebrew”.</em></p>
|
|
<div class="section" id="package-manager">
|
|
<h3>Package Manager<a class="headerlink" href="#package-manager" title="Permalink to this headline">¶</a></h3>
|
|
<p>While Snow Leopard comes with a large number of UNIX utilities, those
|
|
familiar with Linux systems will notice one key component missing: a
|
|
package manager. Mxcl’s <em>Homebrew</em> is the answer.</p>
|
|
<p>To install Homebrew, simply run:</p>
|
|
<div class="highlight-python"><pre>$ ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"</pre>
|
|
</div>
|
|
<p>It’s basic commands are <strong>update</strong>, <strong>install</strong>, and <strong>remove</strong>.</p>
|
|
<p>And we can now install Python 2.7:</p>
|
|
<div class="highlight-python"><pre>$ brew install python --framework</pre>
|
|
</div>
|
|
<p>The <tt class="docutils literal"><span class="pre">--framework</span></tt> option tells Homebrew to compile a Framework-style Python build, rather than a UNIX-style build. The outdated version of Python that Snow Leopard comes packaged with
|
|
is built as a Framework, so this helps avoid some future module installation
|
|
bugs.</p>
|
|
<p><em>Don’t forget to update your environment PATH.</em></p>
|
|
</div>
|
|
<div class="section" id="building-from-source">
|
|
<h3>Building From Source<a class="headerlink" href="#building-from-source" title="Permalink to this headline">¶</a></h3>
|
|
</div>
|
|
<div class="section" id="distribute-pip">
|
|
<h3>Distribute & Pip<a class="headerlink" href="#distribute-pip" title="Permalink to this headline">¶</a></h3>
|
|
<p><em>Distribute</em> is a fantastic drop-in replacement for <em>easy_install</em> and
|
|
<em>setuptools</em>. It allows you to install and manage python packages from
|
|
pypi.python.org, amongst a few other sources. It also plays well with
|
|
<em>virtualenv</em> and user-enviornments.</p>
|
|
<p><strong>easy_install</strong> is considered by many to be a deprecated system, so we
|
|
will install it’s replacement: <strong>pip</strong>. Pip allows for uninstallation
|
|
of packages, and is actively maintained, unlike setuptool’s easy_install.</p>
|
|
<p>To install <em>pip</em> and Distribute’s <em>easy_install</em>:</p>
|
|
<p>If you have homebrew:</p>
|
|
<div class="highlight-python"><pre>$ brew install pip</pre>
|
|
</div>
|
|
<p>...And, if you’re a masochist:</p>
|
|
<div class="highlight-python"><pre>$ curl -O http://python-distribute.org/distribute_setup.py
|
|
$ python distribute_setup.py
|
|
|
|
$ easy_install pip</pre>
|
|
</div>
|
|
<p>To install <tt class="docutils literal"><span class="pre">pip</span></tt>:</p>
|
|
<p>Hopefully you’ll never have to use <strong>easy_install</strong> again.</p>
|
|
</div>
|
|
<div class="section" id="updating-python">
|
|
<h3>Updating Python<a class="headerlink" href="#updating-python" title="Permalink to this headline">¶</a></h3>
|
|
<p>Homebrew makes it simple.</p>
|
|
<div class="highlight-python"><pre>$ brew update
|
|
$ brew install --force python</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="windows">
|
|
<h2>Windows<a class="headerlink" href="#windows" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="prerequisites">
|
|
<h3>Prerequisites:<a class="headerlink" href="#prerequisites" title="Permalink to this headline">¶</a></h3>
|
|
<ul class="simple">
|
|
<li>Python2.7 (x86) from Python.org</li>
|
|
<li>Microsoft Visual Studio</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="step-1-install-distribute-pip">
|
|
<h3>Step 1: Install Distribute & Pip<a class="headerlink" href="#step-1-install-distribute-pip" title="Permalink to this headline">¶</a></h3>
|
|
<p><strong>Distribute</strong> is a fantastic drop-in replacement for <strong>easy_install</strong> and <strong>setuptools</strong>. It allows you to install and manage python packages from PyPi, amongst a few other sources.</p>
|
|
<dl class="docutils">
|
|
<dt>To install it, run the python script available here:</dt>
|
|
<dd><<a class="reference external" href="http://python-distribute.org/distribute_setup.py">http://python-distribute.org/distribute_setup.py</a>></dd>
|
|
</dl>
|
|
<p>Make sure that <tt class="docutils literal"><span class="pre">`C:\Python27\`</span></tt>, and <tt class="docutils literal"><span class="pre">`C:\Python27\Scripts`</span></tt> are in your PATH.</p>
|
|
<p><strong>easy_install</strong> is considered by many to be a deprecated system, so we will install it’s replacement: <strong>pip</strong>. Pip allows for uninstallation of packages, and is actively maintained, unlike setuptool’s easy_install.</p>
|
|
<p>To install pip, simply run:</p>
|
|
<div class="highlight-python"><pre>$ easy_install pip</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="linux-ubuntu">
|
|
<h2>Linux (Ubuntu)<a class="headerlink" href="#linux-ubuntu" title="Permalink to this headline">¶</a></h2>
|
|
<p>Oneiric Ocelot, the latest version of Ubuntu, <strong>comes with Python 2.7 out of the box</strong>. Python 3.2 can be installed and run with the following commands:</p>
|
|
<div class="highlight-python"><pre>$ sudo apt-get install python3-minimal
|
|
$ python3</pre>
|
|
</div>
|
|
<p>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):</p>
|
|
<div class="highlight-python"><pre>$ sudo apt-get install python-software-properties
|
|
$ sudo add-apt-repository ppa:fkrull/deadsnakes
|
|
$ sudo apt-get update
|
|
$ sudo apt-get install python2.5</pre>
|
|
</div>
|
|
<div class="section" id="installing-setuptools-and-pip">
|
|
<h3>Installing setuptools and pip<a class="headerlink" href="#installing-setuptools-and-pip" title="Permalink to this headline">¶</a></h3>
|
|
<p>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 <tt class="docutils literal"><span class="pre">setuptools</span></tt> package and <tt class="docutils literal"><span class="pre">pip</span></tt> installer:</p>
|
|
<div class="highlight-python"><pre>.. XXX: sudo?</pre>
|
|
</div>
|
|
<blockquote>
|
|
<div>$ wget <a class="reference external" href="http://python-distribute.org/distribute_setup.py">http://python-distribute.org/distribute_setup.py</a>
|
|
$ python distribute_setup.py
|
|
$ wget <a class="reference external" href="https://raw.github.com/pypa/pip/master/contrib/get-pip.py">https://raw.github.com/pypa/pip/master/contrib/get-pip.py</a>
|
|
$ python get-pip.py
|
|
$ rm get-pip.py distribute_setup.py</div></blockquote>
|
|
<p>Now, most Python packages can be installed using the <tt class="docutils literal"><span class="pre">pip</span></tt> command. For example, if we wanted to install Django:</p>
|
|
<div class="highlight-python"><pre>$ sudo pip install django</pre>
|
|
</div>
|
|
<p>A full list of <tt class="docutils literal"><span class="pre">pip</span></tt>‘s capabilities is available by typing <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">--help</span></tt>.</p>
|
|
</div>
|
|
<div class="section" id="linux-manual">
|
|
<h3>Linux (Manual)<a class="headerlink" href="#linux-manual" title="Permalink to this headline">¶</a></h3>
|
|
<p>While your system will quite likely already have Python installation, you might wish to install a different version. This is done in the typical Linux software source install procedure:</p>
|
|
<div class="highlight-python"><pre>$ wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
|
|
$ tar -xvf Python-2.7.2.tgz
|
|
$ cd Python-2.7.2
|
|
$ ./configure
|
|
$ make
|
|
$ make install</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper"><h3><a href="http://python-guide.org">About This Guide</a></h3>
|
|
<p>
|
|
This opinionated guide exists to provide both novice and expert Python developers a best-practice handbook to the installation, configuration, and usage of Python on a daily basis.
|
|
</p>
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">Properly Installing Python</a><ul>
|
|
<li><a class="reference internal" href="#mac-os-x">Mac OS X</a><ul>
|
|
<li><a class="reference internal" href="#package-manager">Package Manager</a></li>
|
|
<li><a class="reference internal" href="#building-from-source">Building From Source</a></li>
|
|
<li><a class="reference internal" href="#distribute-pip">Distribute & Pip</a></li>
|
|
<li><a class="reference internal" href="#updating-python">Updating Python</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#windows">Windows</a><ul>
|
|
<li><a class="reference internal" href="#prerequisites">Prerequisites:</a></li>
|
|
<li><a class="reference internal" href="#step-1-install-distribute-pip">Step 1: Install Distribute & Pip</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#linux-ubuntu">Linux (Ubuntu)</a><ul>
|
|
<li><a class="reference internal" href="#installing-setuptools-and-pip">Installing setuptools and pip</a></li>
|
|
<li><a class="reference internal" href="#linux-manual">Linux (Manual)</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h3>Related Topics</h3>
|
|
<ul>
|
|
<li><a href="../index.html">Documentation overview</a><ul>
|
|
<li>Previous: <a href="which-python.html" title="previous chapter">Picking an Interpreter</a></li>
|
|
<li>Next: <a href="dev-env.html" title="next chapter">Your Development Environment</a></li>
|
|
</ul></li>
|
|
</ul>
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="../_sources/starting/installation.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="footer">
|
|
© Copyright 2011. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project.
|
|
</div>
|
|
<a href="https://github.com/kennethreitz/python-guide" class="github">
|
|
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
|
|
</a>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var _gaq2 = _gaq2 || [];
|
|
_gaq2.push(['_setAccount', 'UA-8742933-10']);
|
|
_gaq2.push(['_setDomainName', 'none']);
|
|
_gaq2.push(['_setAllowLinker', true]);
|
|
_gaq2.push(['_trackPageview']);
|
|
|
|
(function() {
|
|
var ga2 = document.createElement('script'); ga.type = 'text/javascript'; ga2.async = true;
|
|
ga2.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga2, s);
|
|
})();
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
(function() {
|
|
var t = document.createElement('script');
|
|
t.type = 'text/javascript';
|
|
t.async = true;
|
|
t.id = 'gauges-tracker';
|
|
t.setAttribute('data-site-id',
|
|
'4ddc1cfaf5a1f50fcc000001');
|
|
t.src = '//secure.gaug.es/track.js';
|
|
var s = document.getElementsByTagName('script')[0];
|
|
s.parentNode.insertBefore(t, s);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |