Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

174 lines · 6.2 KiB

Last changed by

Use 'venv' consistently for virtualenv directory.Ron DuPlainbefore adoption0d2ffc0

History of this file

Take it

The walk stopped after 200 commits: lines older than 7331ae3 point at it.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 1–11why, one step back
1.. _installation:
23Installation4============56Flask depends on two external libraries, `Werkzeug7<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_.8Werkzeug is a toolkit for WSGI, the standard Python interface between web9applications and a variety of servers for both development and deployment.10Jinja2 renders templates.11

tweaks to styleOri Livnehbefore adoption1a9e082

lines 12–14why, one step back
12So how do you get all that on your computer quickly? There are many ways you
13could do that, but the most kick-ass method is virtualenv, so let's have a look14at that first.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 15why, one step back
15

tweaks to styleOri Livnehbefore adoption1a9e082

lines 16–19why, one step back
16You will need Python 2.5 or higher to get started, so be sure to have an
17up-to-date Python 2.x installation. At the time of writing, the WSGI18specification has not yet been finalized for Python 3, so Flask cannot support19the 3.x series of Python.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 20–25why, one step back
20
21.. _virtualenv:2223virtualenv24----------25

tweaks to styleOri Livnehbefore adoption1a9e082

lines 26–28why, one step back
26Virtualenv is probably what you want to use during development, and if you have
27shell access to your production machines, you'll probably want to use it there,28too.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 29why, one step back
29

tweaks to styleOri Livnehbefore adoption1a9e082

lines 30–37why, one step back
30What problem does virtualenv solve? If you like Python as much as I do,
31chances are you want to use it for other projects besides Flask-based web32applications. But the more projects you have, the more likely it is that you33will be working with different versions of Python itself, or at least different34versions of Python libraries. Let's face it: quite often libraries break35backwards compatibility, and it's unlikely that any serious application will36have zero dependencies. So what do you do if two or more of your projects have37conflicting dependencies?

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 38why, one step back
38

tweaks to styleOri Livnehbefore adoption1a9e082

lines 39–42why, one step back
39Virtualenv to the rescue! Virtualenv enables multiple side-by-side
40installations of Python, one for each project. It doesn't actually install41separate copies of Python, but it does provide a clever way to keep different42project environments isolated. Let's see how virtualenv works.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 43–52why, one step back
43
44If you are on Mac OS X or Linux, chances are that one of the following two45commands will work for you::4647 $ sudo easy_install virtualenv4849or even better::5051 $ sudo pip install virtualenv52

tweaks to styleOri Livnehbefore adoption1a9e082

lines 53–54why, one step back
53One of these will probably install virtualenv on your system. Maybe it's even
54in your package manager. If you use Ubuntu, try::

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 55–59why, one step back
55
56 $ sudo apt-get install python-virtualenv5758If you are on Windows and don't have the `easy_install` command, you must59install it first. Check the :ref:`windows-easy-install` section for more

tweaks to styleOri Livnehbefore adoption1a9e082

lines 60–61why, one step back
60information about how to do that. Once you have it installed, run the same
61commands as above, but without the `sudo` prefix.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 62–63why, one step back
62
63Once you have virtualenv installed, just fire up a shell and create

Use 'venv' consistently for virtualenv directory.Ron DuPlainbefore adoption0d2ffc0

line 64why, one step back
64your own environment. I usually create a project folder and a `venv`

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 65–68why, one step back
65folder within::
6667 $ mkdir myproject68 $ cd myproject

vent and no more .Kenneth Reitzbefore adoption60f7e3a

lines 69–70why, one step back
69 $ virtualenv venv
70 New python executable in venv/bin/python

typos and fixesKenneth Reitzbefore adoption5e84817

line 71why, one step back
71 Installing distribute............done.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 72why, one step back
72

tweaks to styleOri Livnehbefore adoption1a9e082

lines 73–74why, one step back
73Now, whenever you want to work on a project, you only have to activate the
74corresponding environment. On OS X and Linux, do the following::

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 75why, one step back
75

Use "." not "source" for shell sourcing.Ron DuPlainbefore adoptione070ede

line 76why, one step back
76 $ . venv/bin/activate

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 77–79why, one step back
77
78If you are a Windows user, the following command is for you::79

vent and no more .Kenneth Reitzbefore adoption60f7e3a

line 80why, one step back
80 $ venv\scripts\activate

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 81why, one step back
81

tweaks to styleOri Livnehbefore adoption1a9e082

line 82why, one step back
82Either way, you should now be using your virtualenv (notice how the prompt of

tweak to one sentenceOri Livnehbefore adoption593b003

line 83why, one step back
83your shell has changed to show the active environment).

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 84why, one step back
84

tweaks to styleOri Livnehbefore adoption1a9e082

lines 85–86why, one step back
85Now you can just enter the following command to get Flask activated in your
86virtualenv::

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 87why, one step back
87

vent and no more .Kenneth Reitzbefore adoption60f7e3a

line 88why, one step back
88 $ pip install Flask

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 89why, one step back
89

tweaks to styleOri Livnehbefore adoption1a9e082

line 90why, one step back
90A few seconds later and you are good to go.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 91–92why, one step back
91
92

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 93why, one step back
93System-Wide Installation

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 94–95why, one step back
94------------------------
95

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 96why, one step back
96This is possible as well, though I do not recommend it. Just run

Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption3249eeb

line 97why, one step back
97`pip` with root privileges::

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 98why, one step back
98

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 99why, one step back
99 $ sudo pip install Flask

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 100why, one step back
100

tweaks to styleOri Livnehbefore adoption1a9e082

line 101why, one step back
101(On Windows systems, run it in a command-prompt window with administrator

typos and fixesKenneth Reitzbefore adoption5e84817

line 102why, one step back
102privileges, and leave out `sudo`.)

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 103–108why, one step back
103
104105Living on the Edge106------------------107108If you want to work with the latest version of Flask, there are two ways: you

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 109why, one step back
109can either let `pip` pull in the development version, or you can tell

tweaks to styleOri Livnehbefore adoption1a9e082

line 110why, one step back
110it to operate on a git checkout. Either way, virtualenv is recommended.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 111–116why, one step back
111
112Get the git checkout in a new virtualenv and run in development mode::113114 $ git clone http://github.com/mitsuhiko/flask.git115 Initialized empty Git repository in ~/dev/flask/.git/116 $ cd flask

vent and no more .Kenneth Reitzbefore adoption60f7e3a

line 117why, one step back
117 $ virtualenv venv --distribute

typos and fixesKenneth Reitzbefore adoption5e84817

lines 118–119why, one step back
118 New python executable in venv/bin/python
119 Installing distribute............done.

Use "." not "source" for shell sourcing.Ron DuPlainbefore adoptione070ede

line 120why, one step back
120 $ . venv/bin/activate

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 121–125why, one step back
121 $ python setup.py develop
122 ...123 Finished processing dependencies for Flask124125This will pull in the dependencies and activate the git head as the current

tweaks to styleOri Livnehbefore adoption1a9e082

lines 126–127why, one step back
126version inside the virtualenv. Then all you have to do is run ``git pull
127origin`` to update to the latest version.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 128–132why, one step back
128
129To just get the development version without git, do this instead::130131 $ mkdir flask132 $ cd flask

vent and no more .Kenneth Reitzbefore adoption60f7e3a

line 133why, one step back
133 $ virtualenv venv --distribute

Use "." not "source" for shell sourcing.Ron DuPlainbefore adoptione070ede

line 134why, one step back
134 $ . venv/bin/activate

vent and no more .Kenneth Reitzbefore adoption60f7e3a

lines 135–136why, one step back
135 New python executable in venv/bin/python
136 Installing distribute............done.

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 137why, one step back
137 $ pip install Flask==dev

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 138–142why, one step back
138 ...
139 Finished processing dependencies for Flask==dev140141.. _windows-easy-install:142

pip and distribute installationKenneth Reitzbefore adoption4a75198

lines 143–144why, one step back
143`pip` and `distribute` on Windows
144-----------------------------------

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 145why, one step back
145

tweaks to styleOri Livnehbefore adoption1a9e082

line 146why, one step back
146On Windows, installation of `easy_install` is a little bit trickier, but still

pip and distribute installationKenneth Reitzbefore adoption4a75198

lines 147–149why, one step back
147quite 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 to149open your downloads folder and double-click on the file.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

lines 150–153why, one step back
150
151Next, add the `easy_install` command and other Python scripts to the152command search path, by adding your Python installation's Scripts folder153to the `PATH` environment variable. To do that, right-click on the

tweaks to styleOri Livnehbefore adoption1a9e082

line 154why, one step back
154"Computer" icon on the Desktop or in the Start menu, and choose "Properties".

tweaks to style and structureOri Livnehbefore adoptionc34a870

lines 155–159why, one step back
155Then click on "Advanced System settings" (in Windows XP, click on the
156"Advanced" tab instead). Then click on the "Environment variables" button.157Finally, double-click on the "Path" variable in the "System variables" section,158and add the path of your Python interpreter's Scripts folder. Be sure to159delimit it from existing values with a semicolon. Assuming you are using

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 160why, one step back
160Python 2.7 on the default path, add the following value::

tweaks to style and structureOri Livnehbefore adoptionc34a870

line 161why, one step back
161

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 162why, one step back
162

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 163why, one step back
163 ;C:\Python27\Scripts

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 164why, one step back
164

tweaks to styleOri Livnehbefore adoption1a9e082

lines 165–167why, one step back
165And 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 or167Windows 7, it should prompt you for administrator privileges.

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 168why, one step back
168

pip and distribute installationKenneth Reitzbefore adoption4a75198

line 169why, one step back
169Now that you have ``easy_install``, you can use it to install ``pip``::

Update the testsuite to not freak out about a change in Werkzeug 0.8 that changed the behavior of misconfigured hosts.Armin Ronacherbefore adoption7331ae3

line 170why, one step back
170

pip and distribute installationKenneth Reitzbefore adoption4a75198

lines 171–174why, one step back
171 > easy_install pip
172173174.. _distribute_setup.py: http://python-distribute.org/distribute_setup.py