Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

186 lines · 4.9 KiB

Last changed by

Merge branch '1.0-maintenance'David Lordbefore adoption3b45b82

History of this file

Take it

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

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 1–8why, one step back
1.. _installation:
23Installation4============56Python Version7--------------8

Merge pull request #2555 from pallets/deprecate-26-33David Lordbefore adoption05e3840

lines 9–10why, one step back
9We recommend using the latest version of Python 3. Flask supports Python 3.4
10and newer, Python 2.7, and PyPy.

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 11–29why, one step back
11
12Dependencies13------------1415These distributions will be installed automatically when installing Flask.1617* `Werkzeug`_ implements WSGI, the standard Python interface between18 applications and servers.19* `Jinja`_ is a template language that renders the pages your application20 serves.21* `MarkupSafe`_ comes with Jinja. It escapes untrusted input when rendering22 templates to avoid injection attacks.23* `ItsDangerous`_ securely signs data to ensure its integrity. This is used24 to protect Flask's session cookie.25* `Click`_ is a framework for writing command line applications. It provides26 the ``flask`` command and allows adding custom management commands.2728.. _Werkzeug: http://werkzeug.pocoo.org/29.. _Jinja: http://jinja.pocoo.org/

Merge pull request #2709 from davidism/docs-themeDavid Lordbefore adoption5fba092

line 30why, one step back
30.. _MarkupSafe: https://pypi.org/project/MarkupSafe/

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 31–45why, one step back
31.. _ItsDangerous: https://pythonhosted.org/itsdangerous/
32.. _Click: http://click.pocoo.org/3334Optional dependencies35~~~~~~~~~~~~~~~~~~~~~3637These distributions will not be installed automatically. Flask will detect and38use them if you install them.3940* `Blinker`_ provides support for :ref:`signals`.41* `SimpleJSON`_ is a fast JSON implementation that is compatible with42 Python's ``json`` module. It is preferred for JSON operations if it is43 installed.44* `python-dotenv`_ enables support for :ref:`dotenv` when running ``flask``45 commands.

Merge pull request #2490 from davidism/cli-reviewDavid Lordbefore adoption0932d8f

lines 46–47why, one step back
46* `Watchdog`_ provides a faster, more efficient reloader for the development
47 server.

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 48–51why, one step back
48
49.. _Blinker: https://pythonhosted.org/blinker/50.. _SimpleJSON: https://simplejson.readthedocs.io/51.. _python-dotenv: https://github.com/theskumar/python-dotenv#readme

Merge pull request #2490 from davidism/cli-reviewDavid Lordbefore adoption0932d8f

line 52why, one step back
52.. _watchdog: https://pythonhosted.org/watchdog/

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 53–83why, one step back
53
54Virtual environments55--------------------5657Use a virtual environment to manage the dependencies for your project, both in58development and in production.5960What problem does a virtual environment solve? The more Python projects you61have, the more likely it is that you need to work with different versions of62Python libraries, or even Python itself. Newer versions of libraries for one63project can break compatibility in another project.6465Virtual environments are independent groups of Python libraries, one for each66project. Packages installed for one project will not affect other projects or67the operating system's packages.6869Python 3 comes bundled with the :mod:`venv` module to create virtual70environments. If you're using a modern version of Python, you can continue on71to the next section.7273If you're using Python 2, see :ref:`install-install-virtualenv` first.7475.. _install-create-env:7677Create an environment78~~~~~~~~~~~~~~~~~~~~~7980Create a project folder and a :file:`venv` folder within:8182.. code-block:: sh83

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 84–86why, one step back
84 $ mkdir myproject
85 $ cd myproject86 $ python3 -m venv venv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 87–91why, one step back
87
88On Windows:8990.. code-block:: bat91

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 92why, one step back
92 $ py -3 -m venv venv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 93why, one step back
93

Merge branch '1.0-maintenance'David Lordbefore adoption3b45b82

lines 94–95why, one step back
94If you needed to install virtualenv because you are using Python 2, use
95the following command instead:

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 96–98why, one step back
96
97.. code-block:: sh98

Merge branch '1.0-maintenance'David Lordbefore adoption3b45b82

line 99why, one step back
99 $ python2 -m virtualenv venv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 100–104why, one step back
100
101On Windows:102103.. code-block:: bat104

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 105why, one step back
105 > \Python27\Scripts\virtualenv.exe venv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 106why, one step back
106

Merge pull request #2676 from davidism/tutorialDavid Lordbefore adoptionc3e2ff2

lines 107–108why, one step back
107.. _install-activate-env:
108

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 109–115why, one step back
109Activate the environment
110~~~~~~~~~~~~~~~~~~~~~~~~111112Before you work on your project, activate the corresponding environment:113114.. code-block:: sh115

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 117–121why, one step back
117
118On Windows:119120.. code-block:: bat121

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 122why, one step back
122 > venv\Scripts\activate

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 123–132why, one step back
123
124Your shell prompt will change to show the name of the activated environment.125126Install Flask127-------------128129Within the activated environment, use the following command to install Flask:130131.. code-block:: sh132

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 134why, one step back
134

Merge branch '1.0-maintenance'ThiefMasterbefore adoption161c436

lines 135–137why, one step back
135Flask is now installed. Check out the :doc:`/quickstart` or go to the
136:doc:`Documentation Overview </index>`.137

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 138–145why, one step back
138Living on the edge
139~~~~~~~~~~~~~~~~~~140141If you want to work with the latest Flask code before it's released, install or142update the code from the master branch:143144.. code-block:: sh145

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 146why, one step back
146 $ pip install -U https://github.com/pallets/flask/archive/master.tar.gz

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 147–160why, one step back
147
148.. _install-install-virtualenv:149150Install virtualenv151------------------152153If you are using Python 2, the venv module is not available. Instead,154install `virtualenv`_.155156On Linux, virtualenv is provided by your package manager:157158.. code-block:: sh159160 # Debian, Ubuntu

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 161why, one step back
161 $ sudo apt-get install python-virtualenv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 162–163why, one step back
162
163 # CentOS, Fedora

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 164why, one step back
164 $ sudo yum install python-virtualenv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 165–166why, one step back
165
166 # Arch

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 167why, one step back
167 $ sudo pacman -S python-virtualenv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 168–172why, one step back
168
169If you are on Mac OS X or Windows, download `get-pip.py`_, then:170171.. code-block:: sh172

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 173–174why, one step back
173 $ sudo python2 Downloads/get-pip.py
174 $ sudo python2 -m pip install virtualenv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 175–179why, one step back
175
176On Windows, as an administrator:177178.. code-block:: bat179

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 180–181why, one step back
180 > \Python27\python.exe Downloads\get-pip.py
181 > \Python27\python.exe -m pip install virtualenv

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 182why, one step back
182

Merge branch '1.0-maintenance'ThiefMasterbefore adoption161c436

line 183why, one step back
183Now you can return above and :ref:`install-create-env`.

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

lines 184–186why, one step back
184
185.. _virtualenv: https://virtualenv.pypa.io/186.. _get-pip.py: https://bootstrap.pypa.io/get-pip.py