Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 175 lines (124 sloc) 6.365 kB
4aa7621 Updated documentation. Starting to look pretty good
Armin Ronacher authored
1 .. _installation:
2
3 Installation
4 ============
5
f5e5330 Edited the installation guide.
Matt Campbell authored
6 Flask depends on two external libraries, `Werkzeug
4edec48 @mitsuhiko Added installation docs
authored
7 <http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_.
f5e5330 Edited the installation guide.
Matt Campbell authored
8 Werkzeug is a toolkit for WSGI, the standard Python interface between web
9 applications and a variety of servers for both development and deployment.
10 Jinja2 renders templates.
4edec48 @mitsuhiko Added installation docs
authored
11
1a9e082 @atdt tweaks to style
atdt authored
12 So how do you get all that on your computer quickly? There are many ways you
13 could do that, but the most kick-ass method is virtualenv, so let's have a look
14 at that first.
4edec48 @mitsuhiko Added installation docs
authored
15
1a9e082 @atdt tweaks to style
atdt authored
16 You will need Python 2.5 or higher to get started, so be sure to have an
17 up-to-date Python 2.x installation. At the time of writing, the WSGI
18 specification has not yet been finalized for Python 3, so Flask cannot support
19 the 3.x series of Python.
fd06bcf @mitsuhiko Added notes on 3.x
authored
20
931dcc4 @mitsuhiko Fixed a doc bug and added distribtue docs.
authored
21 .. _virtualenv:
22
4edec48 @mitsuhiko Added installation docs
authored
23 virtualenv
24 ----------
25
1a9e082 @atdt tweaks to style
atdt authored
26 Virtualenv is probably what you want to use during development, and if you have
27 shell access to your production machines, you'll probably want to use it there,
28 too.
f5e5330 Edited the installation guide.
Matt Campbell authored
29
1a9e082 @atdt tweaks to style
atdt authored
30 What problem does virtualenv solve? If you like Python as much as I do,
31 chances are you want to use it for other projects besides Flask-based web
32 applications. But the more projects you have, the more likely it is that you
33 will be working with different versions of Python itself, or at least different
34 versions of Python libraries. Let's face it: quite often libraries break
35 backwards compatibility, and it's unlikely that any serious application will
36 have zero dependencies. So what do you do if two or more of your projects have
37 conflicting dependencies?
4edec48 @mitsuhiko Added installation docs
authored
38
1a9e082 @atdt tweaks to style
atdt authored
39 Virtualenv to the rescue! Virtualenv enables multiple side-by-side
40 installations of Python, one for each project. It doesn't actually install
41 separate copies of Python, but it does provide a clever way to keep different
42 project environments isolated. Let's see how virtualenv works.
4edec48 @mitsuhiko Added installation docs
authored
43
f5e5330 Edited the installation guide.
Matt Campbell authored
44 If you are on Mac OS X or Linux, chances are that one of the following two
133920c @maix Fix typo in docs.
maix authored
45 commands will work for you::
4edec48 @mitsuhiko Added installation docs
authored
46
05f36c7 @mitsuhiko Heavily improved documentation
authored
47 $ sudo easy_install virtualenv
4edec48 @mitsuhiko Added installation docs
authored
48
49 or even better::
50
05f36c7 @mitsuhiko Heavily improved documentation
authored
51 $ sudo pip install virtualenv
4edec48 @mitsuhiko Added installation docs
authored
52
1a9e082 @atdt tweaks to style
atdt authored
53 One of these will probably install virtualenv on your system. Maybe it's even
54 in your package manager. If you use Ubuntu, try::
f5e5330 Edited the installation guide.
Matt Campbell authored
55
56 $ sudo apt-get install python-virtualenv
4edec48 @mitsuhiko Added installation docs
authored
57
f5e5330 Edited the installation guide.
Matt Campbell authored
58 If you are on Windows and don't have the `easy_install` command, you must
05f36c7 @mitsuhiko Heavily improved documentation
authored
59 install it first. Check the :ref:`windows-easy-install` section for more
1a9e082 @atdt tweaks to style
atdt authored
60 information about how to do that. Once you have it installed, run the same
61 commands as above, but without the `sudo` prefix.
4edec48 @mitsuhiko Added installation docs
authored
62
f5e5330 Edited the installation guide.
Matt Campbell authored
63 Once you have virtualenv installed, just fire up a shell and create
0d2ffc0 @rduplain Use 'venv' consistently for virtualenv directory.
rduplain authored
64 your own environment. I usually create a project folder and a `venv`
f5e5330 Edited the installation guide.
Matt Campbell authored
65 folder within::
4edec48 @mitsuhiko Added installation docs
authored
66
67 $ mkdir myproject
68 $ cd myproject
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
69 $ virtualenv venv
70 New python executable in venv/bin/python
5e84817 @kennethreitz typos and fixes
kennethreitz authored
71 Installing distribute............done.
4edec48 @mitsuhiko Added installation docs
authored
72
1a9e082 @atdt tweaks to style
atdt authored
73 Now, whenever you want to work on a project, you only have to activate the
74 corresponding environment. On OS X and Linux, do the following::
4edec48 @mitsuhiko Added installation docs
authored
75
e070ede @rduplain Use "." not "source" for shell sourcing.
rduplain authored
76 $ . venv/bin/activate
4edec48 @mitsuhiko Added installation docs
authored
77
78 If you are a Windows user, the following command is for you::
79
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
80 $ venv\scripts\activate
4edec48 @mitsuhiko Added installation docs
authored
81
1a9e082 @atdt tweaks to style
atdt authored
82 Either way, you should now be using your virtualenv (notice how the prompt of
593b003 @atdt tweak to one sentence
atdt authored
83 your shell has changed to show the active environment).
4edec48 @mitsuhiko Added installation docs
authored
84
1a9e082 @atdt tweaks to style
atdt authored
85 Now you can just enter the following command to get Flask activated in your
86 virtualenv::
4edec48 @mitsuhiko Added installation docs
authored
87
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
88 $ pip install Flask
4edec48 @mitsuhiko Added installation docs
authored
89
1a9e082 @atdt tweaks to style
atdt authored
90 A few seconds later and you are good to go.
4edec48 @mitsuhiko Added installation docs
authored
91
92
7ccca13 Fixed various stylistic issues in documentation
FND authored
93 System-Wide Installation
4edec48 @mitsuhiko Added installation docs
authored
94 ------------------------
95
7ccca13 Fixed various stylistic issues in documentation
FND authored
96 This is possible as well, though I do not recommend it. Just run
e08028d @SimonSapin pip vs. easy_install consistency
SimonSapin authored
97 `pip` with root privileges::
4edec48 @mitsuhiko Added installation docs
authored
98
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
99 $ sudo pip install Flask
4edec48 @mitsuhiko Added installation docs
authored
100
1a9e082 @atdt tweaks to style
atdt authored
101 (On Windows systems, run it in a command-prompt window with administrator
5e84817 @kennethreitz typos and fixes
kennethreitz authored
102 privileges, and leave out `sudo`.)
4edec48 @mitsuhiko Added installation docs
authored
103
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
104
07e515b @mitsuhiko Leaving -> living ....
authored
105 Living on the Edge
106 ------------------
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
107
f5e5330 Edited the installation guide.
Matt Campbell authored
108 If you want to work with the latest version of Flask, there are two ways: you
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
109 can either let `pip` pull in the development version, or you can tell
1a9e082 @atdt tweaks to style
atdt authored
110 it to operate on a git checkout. Either way, virtualenv is recommended.
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
111
f5e5330 Edited the installation guide.
Matt Campbell authored
112 Get the git checkout in a new virtualenv and run in development mode::
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
113
114 $ git clone http://github.com/mitsuhiko/flask.git
115 Initialized empty Git repository in ~/dev/flask/.git/
116 $ cd flask
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
117 $ virtualenv venv --distribute
5e84817 @kennethreitz typos and fixes
kennethreitz authored
118 New python executable in venv/bin/python
119 Installing distribute............done.
e070ede @rduplain Use "." not "source" for shell sourcing.
rduplain authored
120 $ . venv/bin/activate
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
121 $ python setup.py develop
122 ...
123 Finished processing dependencies for Flask
124
f5e5330 Edited the installation guide.
Matt Campbell authored
125 This will pull in the dependencies and activate the git head as the current
1a9e082 @atdt tweaks to style
atdt authored
126 version inside the virtualenv. Then all you have to do is run ``git pull
127 origin`` to update to the latest version.
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
128
129 To just get the development version without git, do this instead::
130
131 $ mkdir flask
132 $ cd flask
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
133 $ virtualenv venv --distribute
e070ede @rduplain Use "." not "source" for shell sourcing.
rduplain authored
134 $ . venv/bin/activate
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
135 New python executable in venv/bin/python
136 Installing distribute............done.
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
137 $ pip install Flask==dev
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
138 ...
139 Finished processing dependencies for Flask==dev
140
05f36c7 @mitsuhiko Heavily improved documentation
authored
141 .. _windows-easy-install:
142
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
143 `pip` and `distribute` on Windows
144 -----------------------------------
05f36c7 @mitsuhiko Heavily improved documentation
authored
145
1a9e082 @atdt tweaks to style
atdt authored
146 On Windows, installation of `easy_install` is a little bit trickier, but still
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
147 quite easy. The easiest way to do it is to download the
148 `distribute_setup.py`_ file and run it. The easiest way to run the file is to
149 open your downloads folder and double-click on the file.
f5e5330 Edited the installation guide.
Matt Campbell authored
150
151 Next, add the `easy_install` command and other Python scripts to the
152 command search path, by adding your Python installation's Scripts folder
153 to the `PATH` environment variable. To do that, right-click on the
1a9e082 @atdt tweaks to style
atdt authored
154 "Computer" icon on the Desktop or in the Start menu, and choose "Properties".
c34a870 @atdt tweaks to style and structure
atdt authored
155 Then click on "Advanced System settings" (in Windows XP, click on the
156 "Advanced" tab instead). Then click on the "Environment variables" button.
157 Finally, double-click on the "Path" variable in the "System variables" section,
158 and add the path of your Python interpreter's Scripts folder. Be sure to
159 delimit it from existing values with a semicolon. Assuming you are using
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
160 Python 2.7 on the default path, add the following value::
c34a870 @atdt tweaks to style and structure
atdt authored
161
05f36c7 @mitsuhiko Heavily improved documentation
authored
162
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
163 ;C:\Python27\Scripts
05f36c7 @mitsuhiko Heavily improved documentation
authored
164
1a9e082 @atdt tweaks to style
atdt authored
165 And you are done! To check that it worked, open the Command Prompt and execute
166 ``easy_install``. If you have User Account Control enabled on Windows Vista or
167 Windows 7, it should prompt you for administrator privileges.
05f36c7 @mitsuhiko Heavily improved documentation
authored
168
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
169 Now that you have ``easy_install``, you can use it to install ``pip``::
05f36c7 @mitsuhiko Heavily improved documentation
authored
170
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
171 > easy_install pip
172
173
174 .. _distribute_setup.py: http://python-distribute.org/distribute_setup.py
Something went wrong with that request. Please try again.