1Installation
2============
3
4
5Python Version
6--------------
7
8We recommend using the latest version of Python. Flask supports Python
93.6 and newer.
10
11``async`` support in Flask requires Python 3.7+ for ``contextvars.ContextVar``.
12
13
14Dependencies
15------------
16
17These distributions will be installed automatically when installing Flask.
18
19* `Werkzeug`_ implements WSGI, the standard Python interface between
20  applications and servers.
21* `Jinja`_ is a template language that renders the pages your application
22  serves.
23* `MarkupSafe`_ comes with Jinja. It escapes untrusted input when rendering
24  templates to avoid injection attacks.
25* `ItsDangerous`_ securely signs data to ensure its integrity. This is used
26  to protect Flask's session cookie.
27* `Click`_ is a framework for writing command line applications. It provides
28  the ``flask`` command and allows adding custom management commands.
29
30.. _Werkzeug: https://palletsprojects.com/p/werkzeug/
31.. _Jinja: https://palletsprojects.com/p/jinja/
32.. _MarkupSafe: https://palletsprojects.com/p/markupsafe/
33.. _ItsDangerous: https://palletsprojects.com/p/itsdangerous/
34.. _Click: https://palletsprojects.com/p/click/
35
36
37Optional dependencies
38~~~~~~~~~~~~~~~~~~~~~
39
40These distributions will not be installed automatically. Flask will detect and
41use them if you install them.
42
43* `Blinker`_ provides support for :doc:`signals`.
44* `python-dotenv`_ enables support for :ref:`dotenv` when running ``flask``
45  commands.
46* `Watchdog`_ provides a faster, more efficient reloader for the development
47  server.
48
49.. _Blinker: https://pythonhosted.org/blinker/
50.. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
51.. _watchdog: https://pythonhosted.org/watchdog/
52
53
54Virtual environments
55--------------------
56
57Use a virtual environment to manage the dependencies for your project, both in
58development and in production.
59
60What problem does a virtual environment solve? The more Python projects you
61have, the more likely it is that you need to work with different versions of
62Python libraries, or even Python itself. Newer versions of libraries for one
63project can break compatibility in another project.
64
65Virtual environments are independent groups of Python libraries, one for each
66project. Packages installed for one project will not affect other projects or
67the operating system's packages.
68
69Python comes bundled with the :mod:`venv` module to create virtual
70environments.
71
72
73.. _install-create-env:
74
75Create an environment
76~~~~~~~~~~~~~~~~~~~~~
77
78Create a project folder and a :file:`venv` folder within:
79
80.. tabs::
81
82   .. group-tab:: macOS/Linux
83
84      .. code-block:: text
85
86         $ mkdir myproject
87         $ cd myproject
88         $ python3 -m venv venv
89
90   .. group-tab:: Windows
91
92      .. code-block:: text
93
94         > mkdir myproject
95         > cd myproject
96         > py -3 -m venv venv
97
98
99.. _install-activate-env:
100
101Activate the environment
102~~~~~~~~~~~~~~~~~~~~~~~~
103
104Before you work on your project, activate the corresponding environment:
105
106.. tabs::
107
108   .. group-tab:: macOS/Linux
109
110      .. code-block:: text
111
112         $ . venv/bin/activate
113
114   .. group-tab:: Windows
115
116      .. code-block:: text
117
118         > venv\Scripts\activate
119
120Your shell prompt will change to show the name of the activated
121environment.
122
123
124Install Flask
125-------------
126
127Within the activated environment, use the following command to install
128Flask:
129
130.. code-block:: sh
131
132    $ pip install Flask
133
134Flask is now installed. Check out the :doc:`/quickstart` or go to the
135:doc:`Documentation Overview </index>`.
136