Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

175 lines · 6.3 KiB

Last changed by

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

History of this file

Take it

The walk stopped after 200 commits: lines older than 5aabc40 point at it.

Added changelog entryArmin Ronacherbefore adoption5aabc40

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

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 12–13why, one step back
12So how do you get all that on your computer quickly? There are many ways,
13as this section will explain, but the most kick-ass method is

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 14–60why, one step back
14virtualenv, so let's look at that first.
1516Either way, you will need Python 2.5 or higher to get started, so be sure17to have an up to date Python 2.x installation. At the time of writing,18the WSGI specification is not yet finalized for Python 3, so Flask cannot19support the 3.x series of Python.2021.. _virtualenv:2223virtualenv24----------2526Virtualenv is probably what you want to use during development, and in27production too if you have shell access there.2829What problem does virtualenv solve? If you like Python as I do,30chances are you want to use it for other projects besides Flask-based31web applications. But the more projects you have, the more likely it is32that you will be working with different versions of Python itself, or at33least different versions of Python libraries. Let's face it; quite often34libraries break backwards compatibility, and it's unlikely that any serious35application will have zero dependencies. So what do you do if two or more36of your projects have conflicting dependencies?3738Virtualenv to the rescue! It basically enables multiple side-by-side39installations of Python, one for each project. It doesn't actually40install separate copies of Python, but it does provide a clever way41to keep different project environments isolated.4243So let's see how virtualenv works!4445If you are on Mac OS X or Linux, chances are that one of the following two46commands will work for you::4748 $ sudo easy_install virtualenv4950or even better::5152 $ sudo pip install virtualenv5354One of these will probably install virtualenv on your system. Maybe it's55even in your package manager. If you use Ubuntu, try::5657 $ sudo apt-get install python-virtualenv5859If you are on Windows and don't have the `easy_install` command, you must60install it first. Check the :ref:`windows-easy-install` section for more

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 61why, one step back
61information on how to do that. Once you have it installed, run the

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 62–80why, one step back
62same commands as above, but without the `sudo` prefix.
6364Once you have virtualenv installed, just fire up a shell and create65your own environment. I usually create a project folder and an `env`66folder within::6768 $ mkdir myproject69 $ cd myproject70 $ virtualenv env71 New python executable in env/bin/python72 Installing setuptools............done.7374Now, whenever you want to work on a project, you only have to activate75the corresponding environment. On OS X and Linux, do the following::7677 $ . env/bin/activate7879(Note the space between the dot and the script name. The dot means that80this script should run in the context of the current shell. If this command

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 81why, one step back
81does not work in your shell, try replacing the dot with ``source``.)

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 82–97why, one step back
82
83If you are a Windows user, the following command is for you::8485 $ env\scripts\activate8687Either way, you should now be using your virtualenv (see how the prompt of88your shell has changed to show the virtualenv).8990Now you can just enter the following command to get Flask activated in91your virtualenv::9293 $ easy_install Flask9495A few seconds later you are good to go.9697

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

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

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 99–100why, one step back
99------------------------
100

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 101–102why, one step back
101This is possible as well, though I do not recommend it. Just run
102`easy_install` with root privileges::

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 103–105why, one step back
103
104 $ sudo easy_install Flask105

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 106why, one step back
106(Run it in an Admin shell on Windows systems and without `sudo`.)

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 107–161why, one step back
107
108109Living on the Edge110------------------111112If you want to work with the latest version of Flask, there are two ways: you113can either let `easy_install` pull in the development version, or tell it114to operate on a git checkout. Either way, virtualenv is recommended.115116Get the git checkout in a new virtualenv and run in development mode::117118 $ git clone http://github.com/mitsuhiko/flask.git119 Initialized empty Git repository in ~/dev/flask/.git/120 $ cd flask121 $ virtualenv env122 $ . env/bin/activate123 New python executable in env/bin/python124 Installing setuptools............done.125 $ python setup.py develop126 ...127 Finished processing dependencies for Flask128129This will pull in the dependencies and activate the git head as the current130version inside the virtualenv. Then you just have to ``git pull origin``131to get the latest version.132133To just get the development version without git, do this instead::134135 $ mkdir flask136 $ cd flask137 $ virtualenv env138 $ . env/bin/activate139 New python executable in env/bin/python140 Installing setuptools............done.141 $ easy_install Flask==dev142 ...143 Finished processing dependencies for Flask==dev144145.. _windows-easy-install:146147`easy_install` on Windows148-------------------------149150On Windows, installation of `easy_install` is a little bit trickier because151slightly different rules apply on Windows than on Unix-like systems, but152it's not difficult. The easiest way to do it is to download the153`ez_setup.py`_ file and run it. The easiest way to run the file is to154open your downloads folder and double-click on the file.155156Next, add the `easy_install` command and other Python scripts to the157command search path, by adding your Python installation's Scripts folder158to the `PATH` environment variable. To do that, right-click on the159"Computer" icon on the Desktop or in the Start menu, and choose160"Properties". Then, on Windows Vista and Windows 7 click on "Advanced System161settings"; on Windows XP, click on the "Advanced" tab instead. Then click

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 162why, one step back
162on the "Environment variables" button and double-click on the "Path"

Added changelog entryArmin Ronacherbefore adoption5aabc40

lines 163–175why, one step back
163variable in the "System variables" section. There append the path of your
164Python interpreter's Scripts folder; make sure you delimit it from165existing values with a semicolon. Assuming you are using Python 2.6 on166the default path, add the following value::167168 ;C:\Python26\Scripts169170Then you are done. To check that it worked, open the Command Prompt and171execute ``easy_install``. If you have User Account Control enabled on172Windows Vista or Windows 7, it should prompt you for admin privileges.173174175.. _ez_setup.py: http://peak.telecommunity.com/dist/ez_setup.py