|
|
@ -3,7 +3,7 @@ |
|
|
|
Installation |
|
|
|
Installation |
|
|
|
============ |
|
|
|
============ |
|
|
|
|
|
|
|
|
|
|
|
Flask depends on two external libraries, `Werkzeug |
|
|
|
Flask depends on some external libraries, like `Werkzeug |
|
|
|
<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_. |
|
|
|
<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_. |
|
|
|
Werkzeug is a toolkit for WSGI, the standard Python interface between web |
|
|
|
Werkzeug is a toolkit for WSGI, the standard Python interface between web |
|
|
|
applications and a variety of servers for both development and deployment. |
|
|
|
applications and a variety of servers for both development and deployment. |
|
|
@ -13,7 +13,7 @@ So how do you get all that on your computer quickly? There are many ways you |
|
|
|
could do that, but the most kick-ass method is virtualenv, so let's have a look |
|
|
|
could do that, but the most kick-ass method is virtualenv, so let's have a look |
|
|
|
at that first. |
|
|
|
at that first. |
|
|
|
|
|
|
|
|
|
|
|
You will need Python 2.6 or higher to get started, so be sure to have an |
|
|
|
You will need Python 2.6 or newer to get started, so be sure to have an |
|
|
|
up-to-date Python 2.x installation. For using Flask with Python 3 have a |
|
|
|
up-to-date Python 2.x installation. For using Flask with Python 3 have a |
|
|
|
look at :ref:`python3-support`. |
|
|
|
look at :ref:`python3-support`. |
|
|
|
|
|
|
|
|
|
|
@ -67,7 +67,7 @@ folder within:: |
|
|
|
$ cd myproject |
|
|
|
$ cd myproject |
|
|
|
$ virtualenv venv |
|
|
|
$ virtualenv venv |
|
|
|
New python executable in venv/bin/python |
|
|
|
New python executable in venv/bin/python |
|
|
|
Installing distribute............done. |
|
|
|
Installing setuptools, pip............done. |
|
|
|
|
|
|
|
|
|
|
|
Now, whenever you want to work on a project, you only have to activate the |
|
|
|
Now, whenever you want to work on a project, you only have to activate the |
|
|
|
corresponding environment. On OS X and Linux, do the following:: |
|
|
|
corresponding environment. On OS X and Linux, do the following:: |
|
|
@ -113,9 +113,9 @@ Get the git checkout in a new virtualenv and run in development mode:: |
|
|
|
$ git clone http://github.com/mitsuhiko/flask.git |
|
|
|
$ git clone http://github.com/mitsuhiko/flask.git |
|
|
|
Initialized empty Git repository in ~/dev/flask/.git/ |
|
|
|
Initialized empty Git repository in ~/dev/flask/.git/ |
|
|
|
$ cd flask |
|
|
|
$ cd flask |
|
|
|
$ virtualenv venv --distribute |
|
|
|
$ virtualenv venv |
|
|
|
New python executable in venv/bin/python |
|
|
|
New python executable in venv/bin/python |
|
|
|
Installing distribute............done. |
|
|
|
Installing setuptools, pip............done. |
|
|
|
$ . venv/bin/activate |
|
|
|
$ . venv/bin/activate |
|
|
|
$ python setup.py develop |
|
|
|
$ python setup.py develop |
|
|
|
... |
|
|
|
... |
|
|
@ -129,45 +129,53 @@ To just get the development version without git, do this instead:: |
|
|
|
|
|
|
|
|
|
|
|
$ mkdir flask |
|
|
|
$ mkdir flask |
|
|
|
$ cd flask |
|
|
|
$ cd flask |
|
|
|
$ virtualenv venv --distribute |
|
|
|
$ virtualenv venv |
|
|
|
$ . venv/bin/activate |
|
|
|
$ . venv/bin/activate |
|
|
|
New python executable in venv/bin/python |
|
|
|
New python executable in venv/bin/python |
|
|
|
Installing distribute............done. |
|
|
|
Installing setuptools, pip............done. |
|
|
|
$ pip install Flask==dev |
|
|
|
$ pip install Flask==dev |
|
|
|
... |
|
|
|
... |
|
|
|
Finished processing dependencies for Flask==dev |
|
|
|
Finished processing dependencies for Flask==dev |
|
|
|
|
|
|
|
|
|
|
|
.. _windows-easy-install: |
|
|
|
.. _windows-easy-install: |
|
|
|
|
|
|
|
|
|
|
|
`pip` and `distribute` on Windows |
|
|
|
`pip` and `setuptools` on Windows |
|
|
|
----------------------------------- |
|
|
|
--------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sometimes getting the standard "Python packaging tools" like *pip*, *setuptools* |
|
|
|
|
|
|
|
and *virtualenv* can be a little trickier, but nothing very hard. The two crucial |
|
|
|
|
|
|
|
packages you will need are setuptools and pip - these will let you install |
|
|
|
|
|
|
|
anything else (like virtualenv). Fortunately there are two "bootstrap scripts" |
|
|
|
|
|
|
|
you can run to install either. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you don't currently have either, then `get-pip.py` will install both for you |
|
|
|
|
|
|
|
(you won't need to run ez_setup.py). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`get-pip.py`_ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To install the latest setuptools, you can use its bootstrap file: |
|
|
|
|
|
|
|
|
|
|
|
On Windows, installation of `easy_install` is a little bit trickier, but still |
|
|
|
`ez_setup.py`_ |
|
|
|
quite easy. The easiest way to do it is to download the |
|
|
|
|
|
|
|
`distribute_setup.py`_ file and run it. The easiest way to run the file is to |
|
|
|
|
|
|
|
open your downloads folder and double-click on the file. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Next, add the `easy_install` command and other Python scripts to the |
|
|
|
Either should be double-clickable once you download them. If you already have pip, |
|
|
|
command search path, by adding your Python installation's Scripts folder |
|
|
|
you can upgrade them by running:: |
|
|
|
to the `PATH` environment variable. To do that, right-click on the |
|
|
|
|
|
|
|
"Computer" icon on the Desktop or in the Start menu, and choose "Properties". |
|
|
|
|
|
|
|
Then click on "Advanced System settings" (in Windows XP, click on the |
|
|
|
|
|
|
|
"Advanced" tab instead). Then click on the "Environment variables" button. |
|
|
|
|
|
|
|
Finally, double-click on the "Path" variable in the "System variables" section, |
|
|
|
|
|
|
|
and add the path of your Python interpreter's Scripts folder. Be sure to |
|
|
|
|
|
|
|
delimit it from existing values with a semicolon. Assuming you are using |
|
|
|
|
|
|
|
Python 2.7 on the default path, add the following value:: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
> pip install --upgrade pip setuptools |
|
|
|
|
|
|
|
|
|
|
|
;C:\Python27\Scripts |
|
|
|
Most often, once you pull up a command prompt you want to be able to type ``pip`` |
|
|
|
|
|
|
|
and ``python`` which will run those things, but this might not automatically happen |
|
|
|
|
|
|
|
on Windows, because it doesn't know where those executables are (give either a try!). |
|
|
|
|
|
|
|
|
|
|
|
And you are done! To check that it worked, open the Command Prompt and execute |
|
|
|
To fix this, you should be able to navigate to your Python install directory |
|
|
|
``easy_install``. If you have User Account Control enabled on Windows Vista or |
|
|
|
(e.g ``C:\Python27``), then go to ``Tools``, then ``Scripts``; then find the |
|
|
|
Windows 7, it should prompt you for administrator privileges. |
|
|
|
``win_add2path.py`` file and run that. Open a **new** Command Prompt and |
|
|
|
|
|
|
|
check that you can now just type ``python`` to bring up the interpreter. |
|
|
|
|
|
|
|
|
|
|
|
Now that you have ``easy_install``, you can use it to install ``pip``:: |
|
|
|
Finally, to install `virtualenv`_, you can simply run:: |
|
|
|
|
|
|
|
|
|
|
|
> easy_install pip |
|
|
|
> pip install virtualenv |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Then you can be off on your way following the installation instructions above. |
|
|
|
|
|
|
|
|
|
|
|
.. _distribute_setup.py: http://python-distribute.org/distribute_setup.py |
|
|
|
.. _get-pip.py: https://raw.github.com/pypa/pip/master/contrib/get-pip.py |
|
|
|
|
|
|
|
.. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py |
|
|
|