Skip to content
Myr

Edited the installation guide.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Matt Campbell · committed by Armin Ronacher · parent f3dd3da · Browse files · 1 file+66 added−71 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+66 added−71 removed

  • other:+66 added−71 removed

1 file+66 added−71 removed

modified:docs/installation.rst+66 added-71 removed
1 unmodified line
23Installation4============56Flask is a microframework and yet it depends on external libraries. There7are various ways how you can install that library and this explains each8way and why there are multiple ways.910Flask depends on two external libraries: `Werkzeug6Flask depends on two external libraries, `Werkzeug7<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_.12The first one is responsible for interfacing WSGI the latter for rendering13templates. Now you are maybe asking, what is WSGI? WSGI is a standard14in Python that is basically responsible for ensuring that your application15is behaving in a specific way so that you can run it on different16environments (for example on a local development server, on an Apache2, on17lighttpd, on Google's App Engine or whatever you have in mind).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.1119So how do you get all that on your computer in no time? The most kick-ass20method is virtualenv, so let's look at that first.12So how do you get all that on your computer quickly? There are many ways13which this section will explain, but the most kick-ass method is14virtualenv, so let's look at that first.1516.. _virtualenv:1718virtualenv19----------2027Virtualenv is what you want to use during development and in production if28you have shell access. So first: what does virtualenv do? If you are29like me and you like Python, chances are you want to use it for another30project as well. Now the more projects you have, the more likely it is31that you will be working with different versions of Python itself or at32least an individual library. Because let's face it: quite often libraries33break backwards compatibility and it's unlikely that your application will34not have any dependencies, that just won't happen. So virtualenv to the35rescue!21Virtualenv is probably what you want to use during development, and in22production too if you have shell access there.2337It basically makes it possible to have multiple side-by-side38"installations" of Python, each for your own project. It's not actually39an installation but a clever way to keep things separated.24What problem does virtualenv solve? If you like Python as I do,25chances are you want to use it for other projects besides Flask-based26web applications. But the more projects you have, the more likely it is27that you will be working with different versions of Python itself, or at28least different versions of Python libraries. Let's face it; quite often29libraries break backwards compatibility, and it's unlikely that any serious30application will have zero dependencies. So what do you do if two or more31of your projects have conflicting dependencies?3241So let's see how that works!33Virtualenv to the rescue! It basically enables multiple side-by-side34installations of Python, one for each project. It doesn't actually35install separate copies of Python, but it does provide a clever way36to keep different project environments isolated.3738So let's see how virtualenv works!3943If you are on OS X or Linux chances are that one of the following two40If you are on Mac OS X or Linux, chances are that one of the following two41commands will work for you::4243 $ sudo easy_install virtualenv4445or even better::4647 $ sudo pip install virtualenv4852Chances are you have virtualenv installed on your system then. Maybe it's53even in your package manager (on ubuntu try ``sudo apt-get install54python-virtualenv``).49One of these will probably install virtualenv on your system. Maybe it's50even in your package manager. If you use Ubuntu, try::5156If you are on Windows and missing the `easy_install` command you have to52 $ sudo apt-get install python-virtualenv5354If you are on Windows and don't have the `easy_install` command, you must55install it first. Check the :ref:`windows-easy-install` section for more56information about how to do that. Once you have it installed, run the59same commands as above, but without the `sudo` part.57same commands as above, but without the `sudo` prefix.5861So now that you have virtualenv running just fire up a shell and create62your own environment. I usually create a folder and a `env` folder63within::59Once you have virtualenv installed, just fire up a shell and create60your own environment. I usually create a project folder and an `env`61folder within::6263 $ mkdir myproject64 $ cd myproject65 $ virtualenv env66 New python executable in env/bin/python67 Installing setuptools............done.6871Now you only have to activate it, whenever you work with it. On OS X and72Linux do the following::69Now, whenever you want to work on a project, you only have to activate70the corresponding environment. On OS X and Linux, do the following::7172 $ . env/bin/activate7376(Note the whitespace between the dot and the script name. This means77execute this file in context of the shell. If the dot does not work for78whatever reason in your shell, try substituting it with ``source``)74(Note the space between the dot and the script name. The dot means that75this script should run in the context of the current shell. If this command76does not work in your shell, try replacing the dot with ``source``)7778If you are a Windows user, the following command is for you::7980 $ env\scripts\activate
11 unmodified lines
9293System Wide Installation94------------------------9598This is possible as well, but I would not recommend it. Just run96This is possible as well, but I do not recommend it. Just run97`easy_install` with root rights::98101 sudo easy_install Flask99 $ sudo easy_install Flask100103(Run it in an Admin shell on Windows systems and without the `sudo`).101(Run it in an Admin shell on Windows systems and without `sudo`).102103104Living on the Edge105------------------106109You want to work with the latest version of Flask, there are two ways: you110can either let `easy_install` pull in the development version or tell it111to operate on a git checkout. Either way it's recommended to do that in a112virtualenv.107If you want to work with the latest version of Flask, there are two ways: you108can either let `easy_install` pull in the development version, or tell it109to operate on a git checkout. Either way, virtualenv is recommended.110114Get the git checkout in a new virtualenv and run in develop mode::111Get the git checkout in a new virtualenv and run in development mode::112113 $ git clone http://github.com/mitsuhiko/flask.git114 Initialized empty Git repository in ~/dev/flask/.git/115 $ cd flask
4 unmodified lines
120 $ python setup.py develop121 ...122 Finished processing dependencies for Flask123127This will pull in the dependencies and activate the git head as current128version. Then you just have to ``git pull origin`` to get the latest129version.124This will pull in the dependencies and activate the git head as the current125version inside the virtualenv. Then you just have to ``git pull origin``126to get the latest version.127128To just get the development version without git, do this instead::129130 $ mkdir flask
10 unmodified lines
141142`easy_install` on Windows143-------------------------144148On Windows installation of `easy_install` is a little bit tricker because149on Windows slightly different rules apply, but it's not a biggy. The150easiest way to accomplish that is downloading the `ez_setup.py`_ file and151running it. (Double clicking should do the trick)145On Windows, installation of `easy_install` is a little bit tricker because146slightly different rules apply on Windows than on Unix-like systems, but147it's not difficult. The easiest way to do it is to download the148`ez_setup.py`_ file and run it. The easiest way to run the file is to149open your downloads folder and double-click on the file.150153Once you have done that it's important to add the `easy_install` command154and other Python scripts to the path. To do that you have to add the155Python installation's Script folder to the `PATH` variable.156157To do that, right-click on your "Computer" desktop icon and click158"Properties". On Windows Vista and Windows 7 then click on "Advanced System159settings", on Windows XP click on the "Advanced" tab instead. Then click151Next, 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 the154"Computer" icon on the Desktop or in the Start menu, and choose155"Properties". Then, on Windows Vista and Windows 7 click on "Advanced System156settings"; on Windows XP, click on the "Advanced" tab instead. Then click157on the "Environment variables" button and double click on the "Path"161variable in the "System variables" section.158variable in the "System variables" section. There append the path of your159Python interpreter's Scripts folder; make sure you delimit it from160existing values with a semicolon. Assuming you are using Python 2.6 on161the default path, add the following value::162163There append the path of your Python interpreter's Script folder to the164end of the last (make sure you delimit it from existing values with a165semicolon). Assuming you are using Python 2.6 on the default path, add166the following value::167163 ;C:\Python26\Scripts164170Then you are done. To check that it worked, open the cmd and execute171"easy_install". If you have UAC enabled it should prompt you for admin172privileges.165Then you are done. To check that it worked, open the Command Prompt and166execute ``easy_install``. If you have User Account Control enabled on167Windows Vista or Windows 7, it should prompt you for admin privileges.168169170.. _ez_setup.py: http://peak.telecommunity.com/dist/ez_setup.py