Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 177 lines (120 sloc) 6.415 kb
4aa7621 Updated documentation. Starting to look pretty good
Armin Ronacher authored
1 .. _installation:
2
3 Installation
4 ============
5
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
6 Flask depends on some external libraries, like `Werkzeug
20edb31 @DasIch Fix Pocoo documentation links
DasIch authored
7 <http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/>`_.
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
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
16 You will need Python 2.6 or newer to get started, so be sure to have an
0ac9582 @mitsuhiko Added notes on Python 3
authored
17 up-to-date Python 2.x installation. For using Flask with Python 3 have a
18 look at :ref:`python3-support`.
fd06bcf @mitsuhiko Added notes on 3.x
authored
19
931dcc4 @mitsuhiko Fixed a doc bug and added distribtue docs.
authored
20 .. _virtualenv:
21
4edec48 @mitsuhiko Added installation docs
authored
22 virtualenv
23 ----------
24
1a9e082 @atdt tweaks to style
atdt authored
25 Virtualenv is probably what you want to use during development, and if you have
26 shell access to your production machines, you'll probably want to use it there,
27 too.
f5e5330 Edited the installation guide.
Matt Campbell authored
28
1a9e082 @atdt tweaks to style
atdt authored
29 What problem does virtualenv solve? If you like Python as much as I do,
30 chances are you want to use it for other projects besides Flask-based web
31 applications. But the more projects you have, the more likely it is that you
32 will be working with different versions of Python itself, or at least different
33 versions of Python libraries. Let's face it: quite often libraries break
34 backwards compatibility, and it's unlikely that any serious application will
35 have zero dependencies. So what do you do if two or more of your projects have
36 conflicting dependencies?
4edec48 @mitsuhiko Added installation docs
authored
37
1a9e082 @atdt tweaks to style
atdt authored
38 Virtualenv to the rescue! Virtualenv enables multiple side-by-side
39 installations of Python, one for each project. It doesn't actually install
40 separate copies of Python, but it does provide a clever way to keep different
41 project environments isolated. Let's see how virtualenv works.
4edec48 @mitsuhiko Added installation docs
authored
42
f5e5330 Edited the installation guide.
Matt Campbell authored
43 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
44 commands will work for you::
4edec48 @mitsuhiko Added installation docs
authored
45
05f36c7 @mitsuhiko Heavily improved documentation
authored
46 $ sudo easy_install virtualenv
4edec48 @mitsuhiko Added installation docs
authored
47
48 or even better::
49
05f36c7 @mitsuhiko Heavily improved documentation
authored
50 $ sudo pip install virtualenv
4edec48 @mitsuhiko Added installation docs
authored
51
1a9e082 @atdt tweaks to style
atdt authored
52 One of these will probably install virtualenv on your system. Maybe it's even
53 in your package manager. If you use Ubuntu, try::
f5e5330 Edited the installation guide.
Matt Campbell authored
54
55 $ sudo apt-get install python-virtualenv
4edec48 @mitsuhiko Added installation docs
authored
56
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
57 If you are on Windows and don't have the :command:`easy_install` command, you must
05f36c7 @mitsuhiko Heavily improved documentation
authored
58 install it first. Check the :ref:`windows-easy-install` section for more
1a9e082 @atdt tweaks to style
atdt authored
59 information about how to do that. Once you have it installed, run the same
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
60 commands as above, but without the :command:`sudo` prefix.
4edec48 @mitsuhiko Added installation docs
authored
61
f5e5330 Edited the installation guide.
Matt Campbell authored
62 Once you have virtualenv installed, just fire up a shell and create
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
63 your own environment. I usually create a project folder and a :file:`venv`
f5e5330 Edited the installation guide.
Matt Campbell authored
64 folder within::
4edec48 @mitsuhiko Added installation docs
authored
65
66 $ mkdir myproject
67 $ cd myproject
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
68 $ virtualenv venv
69 New python executable in venv/bin/python
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
70 Installing setuptools, pip............done.
4edec48 @mitsuhiko Added installation docs
authored
71
1a9e082 @atdt tweaks to style
atdt authored
72 Now, whenever you want to work on a project, you only have to activate the
73 corresponding environment. On OS X and Linux, do the following::
4edec48 @mitsuhiko Added installation docs
authored
74
e070ede @rduplain Use "." not "source" for shell sourcing.
rduplain authored
75 $ . venv/bin/activate
4edec48 @mitsuhiko Added installation docs
authored
76
77 If you are a Windows user, the following command is for you::
78
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
79 $ venv\scripts\activate
4edec48 @mitsuhiko Added installation docs
authored
80
1a9e082 @atdt tweaks to style
atdt authored
81 Either way, you should now be using your virtualenv (notice how the prompt of
593b003 @atdt tweak to one sentence
atdt authored
82 your shell has changed to show the active environment).
4edec48 @mitsuhiko Added installation docs
authored
83
a8fd417 @lord63 Update installation.rst
lord63 authored
84 And if you want to go back to the real world, use the following command::
85
86 $ deactivate
87
47b5c09 @moonshadow fix typo
moonshadow authored
88 After doing this, the prompt of your shell should be as familiar as before.
a8fd417 @lord63 Update installation.rst
lord63 authored
89
c44a611 @lord63 Update installation.rst
lord63 authored
90 Now, let's move on. Enter the following command to get Flask activated in your
1a9e082 @atdt tweaks to style
atdt authored
91 virtualenv::
4edec48 @mitsuhiko Added installation docs
authored
92
60f7e3a @kennethreitz vent and no more .
kennethreitz authored
93 $ pip install Flask
4edec48 @mitsuhiko Added installation docs
authored
94
1a9e082 @atdt tweaks to style
atdt authored
95 A few seconds later and you are good to go.
4edec48 @mitsuhiko Added installation docs
authored
96
97
7ccca13 Fixed various stylistic issues in documentation
FND authored
98 System-Wide Installation
4edec48 @mitsuhiko Added installation docs
authored
99 ------------------------
100
7ccca13 Fixed various stylistic issues in documentation
FND authored
101 This is possible as well, though I do not recommend it. Just run
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
102 :command:`pip` with root privileges::
4edec48 @mitsuhiko Added installation docs
authored
103
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
104 $ sudo pip install Flask
4edec48 @mitsuhiko Added installation docs
authored
105
1a9e082 @atdt tweaks to style
atdt authored
106 (On Windows systems, run it in a command-prompt window with administrator
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
107 privileges, and leave out :command:`sudo`.)
4edec48 @mitsuhiko Added installation docs
authored
108
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
109
07e515b @mitsuhiko Leaving -> living ....
authored
110 Living on the Edge
111 ------------------
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
112
f5e5330 Edited the installation guide.
Matt Campbell authored
113 If you want to work with the latest version of Flask, there are two ways: you
02694d6 @defuz docs: :command:`pip`, :option:`--debug`
defuz authored
114 can either let :command:`pip` pull in the development version, or you can tell
1a9e082 @atdt tweaks to style
atdt authored
115 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
116
f5e5330 Edited the installation guide.
Matt Campbell authored
117 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
118
119 $ git clone http://github.com/mitsuhiko/flask.git
120 Initialized empty Git repository in ~/dev/flask/.git/
121 $ cd flask
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
122 $ virtualenv venv
5e84817 @kennethreitz typos and fixes
kennethreitz authored
123 New python executable in venv/bin/python
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
124 Installing setuptools, pip............done.
e070ede @rduplain Use "." not "source" for shell sourcing.
rduplain authored
125 $ . venv/bin/activate
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
126 $ python setup.py develop
127 ...
128 Finished processing dependencies for Flask
129
f5e5330 Edited the installation guide.
Matt Campbell authored
130 This will pull in the dependencies and activate the git head as the current
1a9e082 @atdt tweaks to style
atdt authored
131 version inside the virtualenv. Then all you have to do is run ``git pull
132 origin`` to update to the latest version.
3d32017 @mitsuhiko Added instructions about how to run the latest development version.
authored
133
134
05f36c7 @mitsuhiko Heavily improved documentation
authored
135 .. _windows-easy-install:
136
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
137 `pip` and `setuptools` on Windows
138 ---------------------------------
139
140 Sometimes getting the standard "Python packaging tools" like *pip*, *setuptools*
141 and *virtualenv* can be a little trickier, but nothing very hard. The two crucial
142 packages you will need are setuptools and pip - these will let you install
143 anything else (like virtualenv). Fortunately there are two "bootstrap scripts"
144 you can run to install either.
145
146 If you don't currently have either, then `get-pip.py` will install both for you
147 (you won't need to run ez_setup.py).
148
149 `get-pip.py`_
05f36c7 @mitsuhiko Heavily improved documentation
authored
150
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
151 To install the latest setuptools, you can use its bootstrap file:
f5e5330 Edited the installation guide.
Matt Campbell authored
152
5562acf @defuz docs: fix warnings
defuz authored
153 `ez_setup.py`_
c34a870 @atdt tweaks to style and structure
atdt authored
154
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
155 Either should be double-clickable once you download them. If you already have pip,
156 you can upgrade them by running::
05f36c7 @mitsuhiko Heavily improved documentation
authored
157
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
158 > pip install --upgrade pip setuptools
05f36c7 @mitsuhiko Heavily improved documentation
authored
159
5562acf @defuz docs: fix warnings
defuz authored
160 Most often, once you pull up a command prompt you want to be able to type :command:`pip`
161 and :command:`python` which will run those things, but this might not automatically happen
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
162 on Windows, because it doesn't know where those executables are (give either a try!).
05f36c7 @mitsuhiko Heavily improved documentation
authored
163
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
164 To fix this, you should be able to navigate to your Python install directory
7e157ee @defuz docs: ``http://...``
defuz authored
165 (e.g :file:`C:\Python27`), then go to :file:`Tools`, then :file:`Scripts`; then find the
166 :file:`win_add2path.py` file and run that. Open a **new** Command Prompt and
5562acf @defuz docs: fix warnings
defuz authored
167 check that you can now just type :command:`python` to bring up the interpreter.
05f36c7 @mitsuhiko Heavily improved documentation
authored
168
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
169 Finally, to install `virtualenv`_, you can simply run::
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
170
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
171 > pip install virtualenv
22219f5 @nicorevin Update doclinks
nicorevin authored
172
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
173 Then you can be off on your way following the installation instructions above.
4a75198 @kennethreitz pip and distribute installation
kennethreitz authored
174
22219f5 @nicorevin Update doclinks
nicorevin authored
175 .. _get-pip.py: https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
a8e88be @Ivoz Update windows installation and other notes
Ivoz authored
176 .. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Something went wrong with that request. Please try again.