Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/studio/static/doc/flask-docs/installation.html
blob: bdb5661170d4fa1e91002ffc072a23fb8e3a6fc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

<!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>Installation &mdash; Flask 0.8 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.8',
        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="Flask 0.8 documentation" href="index.html" />
    <link rel="next" title="Quickstart" href="quickstart.html" />
    <link rel="prev" title="Foreword" href="foreword.html" />
   
  
  <link rel="apple-touch-icon" href="_static/touch-icon.png" />
  
  <link media="only screen and (max-device-width: 480px)" href="_static/small_flask.css" type= "text/css" rel="stylesheet" />

  </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="quickstart.html" title="Quickstart"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="foreword.html" title="Foreword"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Flask 0.8 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="installation">
<span id="id1"></span><h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<p>Flask depends on two external libraries, <a class="reference external" href="http://werkzeug.pocoo.org/">Werkzeug</a> and <a class="reference external" href="http://jinja.pocoo.org/2/">Jinja2</a>.
Werkzeug is a toolkit for WSGI, the standard Python interface between web
applications and a variety of servers for both development and deployment.
Jinja2 renders templates.</p>
<p>So how do you get all that on your computer quickly?  There are many ways
which this section will explain, but the most kick-ass method is
virtualenv, so let&#8217;s look at that first.</p>
<p>Either way, you will need Python 2.5 or higher to get started, so be sure
to have an up to date Python 2.x installation.  At the time of writing,
the WSGI specification is not yet finalized for Python 3, so Flask cannot
support the 3.x series of Python.</p>
<div class="section" id="virtualenv">
<span id="id2"></span><h2>virtualenv<a class="headerlink" href="#virtualenv" title="Permalink to this headline">¶</a></h2>
<p>Virtualenv is probably what you want to use during development, and in
production too if you have shell access there.</p>
<p>What problem does virtualenv solve?  If you like Python as I do,
chances are you want to use it for other projects besides Flask-based
web applications.  But the more projects you have, the more likely it is
that you will be working with different versions of Python itself, or at
least different versions of Python libraries.  Let&#8217;s face it; quite often
libraries break backwards compatibility, and it&#8217;s unlikely that any serious
application will have zero dependencies.  So what do you do if two or more
of your projects have conflicting dependencies?</p>
<p>Virtualenv to the rescue!  It basically enables multiple side-by-side
installations of Python, one for each project.  It doesn&#8217;t actually
install separate copies of Python, but it does provide a clever way
to keep different project environments isolated.</p>
<p>So let&#8217;s see how virtualenv works!</p>
<p>If you are on Mac OS X or Linux, chances are that one of the following two
commands will work for you:</p>
<div class="highlight-python"><pre>$ sudo easy_install virtualenv</pre>
</div>
<p>or even better:</p>
<div class="highlight-python"><pre>$ sudo pip install virtualenv</pre>
</div>
<p>One of these will probably install virtualenv on your system.  Maybe it&#8217;s
even in your package manager.  If you use Ubuntu, try:</p>
<div class="highlight-python"><pre>$ sudo apt-get install python-virtualenv</pre>
</div>
<p>If you are on Windows and don&#8217;t have the <cite>easy_install</cite> command, you must
install it first.  Check the <a class="reference internal" href="#windows-easy-install"><em>easy_install on Windows</em></a> section for more
information about how to do that.  Once you have it installed, run the
same commands as above, but without the <cite>sudo</cite> prefix.</p>
<p>Once you have virtualenv installed, just fire up a shell and create
your own environment.  I usually create a project folder and an <cite>env</cite>
folder within:</p>
<div class="highlight-python"><pre>$ mkdir myproject
$ cd myproject
$ virtualenv env
New python executable in env/bin/python
Installing setuptools............done.</pre>
</div>
<p>Now, whenever you want to work on a project, you only have to activate
the corresponding environment.  On OS X and Linux, do the following:</p>
<div class="highlight-python"><pre>$ . env/bin/activate</pre>
</div>
<p>(Note the space between the dot and the script name.  The dot means that
this script should run in the context of the current shell.  If this command
does not work in your shell, try replacing the dot with <tt class="docutils literal"><span class="pre">source</span></tt>)</p>
<p>If you are a Windows user, the following command is for you:</p>
<div class="highlight-python"><pre>$ env\scripts\activate</pre>
</div>
<p>Either way, you should now be using your virtualenv (see how the prompt of
your shell has changed to show the virtualenv).</p>
<p>Now you can just enter the following command to get Flask activated in
your virtualenv:</p>
<div class="highlight-python"><pre>$ easy_install Flask</pre>
</div>
<p>A few seconds later you are good to go.</p>
</div>
<div class="section" id="system-wide-installation">
<h2>System Wide Installation<a class="headerlink" href="#system-wide-installation" title="Permalink to this headline">¶</a></h2>
<p>This is possible as well, but I do not recommend it.  Just run
<cite>easy_install</cite> with root rights:</p>
<div class="highlight-python"><pre>$ sudo easy_install Flask</pre>
</div>
<p>(Run it in an Admin shell on Windows systems and without <cite>sudo</cite>).</p>
</div>
<div class="section" id="living-on-the-edge">
<h2>Living on the Edge<a class="headerlink" href="#living-on-the-edge" title="Permalink to this headline">¶</a></h2>
<p>If you want to work with the latest version of Flask, there are two ways: you
can either let <cite>easy_install</cite> pull in the development version, or tell it
to operate on a git checkout.  Either way, virtualenv is recommended.</p>
<p>Get the git checkout in a new virtualenv and run in development mode:</p>
<div class="highlight-python"><pre>$ git clone http://github.com/mitsuhiko/flask.git
Initialized empty Git repository in ~/dev/flask/.git/
$ cd flask
$ virtualenv env
$ . env/bin/activate
New python executable in env/bin/python
Installing setuptools............done.
$ python setup.py develop
...
Finished processing dependencies for Flask</pre>
</div>
<p>This will pull in the dependencies and activate the git head as the current
version inside the virtualenv.  Then you just have to <tt class="docutils literal"><span class="pre">git</span> <span class="pre">pull</span> <span class="pre">origin</span></tt>
to get the latest version.</p>
<p>To just get the development version without git, do this instead:</p>
<div class="highlight-python"><pre>$ mkdir flask
$ cd flask
$ virtualenv env
$ . env/bin/activate
New python executable in env/bin/python
Installing setuptools............done.
$ easy_install Flask==dev
...
Finished processing dependencies for Flask==dev</pre>
</div>
</div>
<div class="section" id="easy-install-on-windows">
<span id="windows-easy-install"></span><h2><cite>easy_install</cite> on Windows<a class="headerlink" href="#easy-install-on-windows" title="Permalink to this headline">¶</a></h2>
<p>On Windows, installation of <cite>easy_install</cite> is a little bit trickier because
slightly different rules apply on Windows than on Unix-like systems, but
it&#8217;s not difficult.  The easiest way to do it is to download the
<a class="reference external" href="http://peak.telecommunity.com/dist/ez_setup.py">ez_setup.py</a> file and run it.  The easiest way to run the file is to
open your downloads folder and double-click on the file.</p>
<p>Next, add the <cite>easy_install</cite> command and other Python scripts to the
command search path, by adding your Python installation&#8217;s Scripts folder
to the <cite>PATH</cite> environment variable.  To do that, right-click on the
&#8220;Computer&#8221; icon on the Desktop or in the Start menu, and choose
&#8220;Properties&#8221;.  Then, on Windows Vista and Windows 7 click on &#8220;Advanced System
settings&#8221;; on Windows XP, click on the &#8220;Advanced&#8221; tab instead.  Then click
on the &#8220;Environment variables&#8221; button and double click on the &#8220;Path&#8221;
variable in the &#8220;System variables&#8221; section.  There append the path of your
Python interpreter&#8217;s Scripts folder; make sure you delimit it from
existing values with a semicolon.  Assuming you are using Python 2.6 on
the default path, add the following value:</p>
<div class="highlight-python"><pre>;C:\Python26\Scripts</pre>
</div>
<p>Then you are done.  To check that it worked, open the Command Prompt and
execute <tt class="docutils literal"><span class="pre">easy_install</span></tt>.  If you have User Account Control enabled on
Windows Vista or Windows 7, it should prompt you for admin privileges.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
  <img class="logo" src="_static/flask.png" alt="Logo"/>
</a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Installation</a><ul>
<li><a class="reference internal" href="#virtualenv">virtualenv</a></li>
<li><a class="reference internal" href="#system-wide-installation">System Wide Installation</a></li>
<li><a class="reference internal" href="#living-on-the-edge">Living on the Edge</a></li>
<li><a class="reference internal" href="#easy-install-on-windows"><cite>easy_install</cite> on Windows</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="foreword.html" title="previous chapter">Foreword</a></li>
      <li>Next: <a href="quickstart.html" title="next chapter">Quickstart</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/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">
      &copy; Copyright 2010, Armin Ronacher.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>