Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

176 lines · 6.3 KiB

Last changed by

Merge pull request #1292 from moonshadow/fix_typoMarkus Unterwaditzerbefore adoptionb292013

History of this file

Take it

The walk stopped after 200 commits: lines older than 36d70d8 point at it.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 1–5why, one step back
1.. _installation:
23Installation4============5

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

line 6why, one step back
6Flask depends on some external libraries, like `Werkzeug

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

line 7why, one step back
7<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/>`_.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 8–15why, one step back
8Werkzeug is a toolkit for WSGI, the standard Python interface between web
9applications and a variety of servers for both development and deployment.10Jinja2 renders templates.1112So how do you get all that on your computer quickly? There are many ways you13could do that, but the most kick-ass method is virtualenv, so let's have a look14at that first.15

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

line 16why, one step back
16You will need Python 2.6 or newer to get started, so be sure to have an

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 17–56why, one step back
17up-to-date Python 2.x installation. For using Flask with Python 3 have a
18look at :ref:`python3-support`.1920.. _virtualenv:2122virtualenv23----------2425Virtualenv is probably what you want to use during development, and if you have26shell access to your production machines, you'll probably want to use it there,27too.2829What problem does virtualenv solve? If you like Python as much as I do,30chances are you want to use it for other projects besides Flask-based web31applications. But the more projects you have, the more likely it is that you32will be working with different versions of Python itself, or at least different33versions of Python libraries. Let's face it: quite often libraries break34backwards compatibility, and it's unlikely that any serious application will35have zero dependencies. So what do you do if two or more of your projects have36conflicting dependencies?3738Virtualenv to the rescue! Virtualenv enables multiple side-by-side39installations of Python, one for each project. It doesn't actually install40separate copies of Python, but it does provide a clever way to keep different41project environments isolated. Let's see how virtualenv works.4243If you are on Mac OS X or Linux, chances are that one of the following two44commands will work for you::4546 $ sudo easy_install virtualenv4748or even better::4950 $ sudo pip install virtualenv5152One of these will probably install virtualenv on your system. Maybe it's even53in your package manager. If you use Ubuntu, try::5455 $ sudo apt-get install python-virtualenv56

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 57why, one step back
57If you are on Windows and don't have the :command:`easy_install` command, you must

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 58–59why, one step back
58install it first. Check the :ref:`windows-easy-install` section for more
59information about how to do that. Once you have it installed, run the same

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 60why, one step back
60commands as above, but without the :command:`sudo` prefix.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

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

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

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

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 64–69why, one step back
64folder within::
6566 $ mkdir myproject67 $ cd myproject68 $ virtualenv venv69 New python executable in venv/bin/python

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

line 70why, one step back
70 Installing setuptools, pip............done.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 71–83why, one step back
71
72Now, whenever you want to work on a project, you only have to activate the73corresponding environment. On OS X and Linux, do the following::7475 $ . venv/bin/activate7677If you are a Windows user, the following command is for you::7879 $ venv\scripts\activate8081Either way, you should now be using your virtualenv (notice how the prompt of82your shell has changed to show the active environment).83

Merge pull request #1088 from lord63/masterKenneth Reitzbefore adoption8efbae9

lines 84–87why, one step back
84And if you want to go back to the real world, use the following command::
8586 $ deactivate87

Merge pull request #1292 from moonshadow/fix_typoMarkus Unterwaditzerbefore adoptionb292013

line 88why, one step back
88After doing this, the prompt of your shell should be as familiar as before.

Merge pull request #1088 from lord63/masterKenneth Reitzbefore adoption8efbae9

lines 89–90why, one step back
89
90Now, let's move on. Enter the following command to get Flask activated in your

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 91–101why, one step back
91virtualenv::
9293 $ pip install Flask9495A few seconds later and you are good to go.969798System-Wide Installation99------------------------100101This is possible as well, though I do not recommend it. Just run

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

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

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 103–106why, one step back
103
104 $ sudo pip install Flask105106(On Windows systems, run it in a command-prompt window with administrator

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 107why, one step back
107privileges, and leave out :command:`sudo`.)

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 108–113why, one step back
108
109110Living on the Edge111------------------112113If you want to work with the latest version of Flask, there are two ways: you

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

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

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 115–121why, one step back
115it to operate on a git checkout. Either way, virtualenv is recommended.
116117Get the git checkout in a new virtualenv and run in development mode::118119 $ git clone http://github.com/mitsuhiko/flask.git120 Initialized empty Git repository in ~/dev/flask/.git/121 $ cd flask

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

line 122why, one step back
122 $ virtualenv venv

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 123why, one step back
123 New python executable in venv/bin/python

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

line 124why, one step back
124 Installing setuptools, pip............done.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

lines 125–136why, one step back
125 $ . venv/bin/activate
126 $ python setup.py develop127 ...128 Finished processing dependencies for Flask129130This will pull in the dependencies and activate the git head as the current131version inside the virtualenv. Then all you have to do is run ``git pull132origin`` to update to the latest version.133134135.. _windows-easy-install:136

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

lines 137–138why, one step back
137`pip` and `setuptools` on Windows
138---------------------------------

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 139why, one step back
139

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

lines 140–144why, one step back
140Sometimes getting the standard "Python packaging tools" like *pip*, *setuptools*
141and *virtualenv* can be a little trickier, but nothing very hard. The two crucial142packages you will need are setuptools and pip - these will let you install143anything else (like virtualenv). Fortunately there are two "bootstrap scripts"144you can run to install either.

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 145why, one step back
145

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

lines 146–147why, one step back
146If 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).

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 148why, one step back
148

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

line 149why, one step back
149`get-pip.py`_

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 150why, one step back
150

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

line 151why, one step back
151To install the latest setuptools, you can use its bootstrap file:

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 152why, one step back
152

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

line 153why, one step back
153`ez_setup.py`_

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 154why, one step back
154

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

lines 155–156why, one step back
155Either should be double-clickable once you download them. If you already have pip,
156you can upgrade them by running::

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 157why, one step back
157

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

line 158why, one step back
158 > pip install --upgrade pip setuptools

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 159why, one step back
159

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

lines 160–161why, one step back
160Most often, once you pull up a command prompt you want to be able to type :command:`pip`
161and :command:`python` which will run those things, but this might not automatically happen

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

line 162why, one step back
162on Windows, because it doesn't know where those executables are (give either a try!).

Merge pull request #843 from wbowlin/masterDaniel Neuhäuserbefore adoption36d70d8

line 163why, one step back
163

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

line 164why, one step back
164To fix this, you should be able to navigate to your Python install directory

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

lines 165–167why, one step back
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 and167check that you can now just type :command:`python` to bring up the interpreter.

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

lines 168–171why, one step back
168
169Finally, to install `virtualenv`_, you can simply run::170171 > pip install virtualenv

Merge pull request #1132 from nicorevin/update_linksDaniel Neuhäuserbefore adoption8d3ee01

line 172why, one step back
172

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

lines 173–174why, one step back
173Then you can be off on your way following the installation instructions above.
174

Merge pull request #1132 from nicorevin/update_linksDaniel Neuhäuserbefore adoption8d3ee01

line 175why, one step back
175.. _get-pip.py: https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py

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

line 176why, one step back
176.. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py