Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

144 lines · 3.7 KiB

Last changed by

Merge pull request #5072 from pallets/drop-py37David Lordbefore adoptionb4345cb

History of this file

Take it

1Installation2============345Python Version6--------------78We recommend using the latest version of Python. Flask supports Python 3.8 and newer.91011Dependencies12------------1314These distributions will be installed automatically when installing Flask.1516* `Werkzeug`_ implements WSGI, the standard Python interface between17  applications and servers.18* `Jinja`_ is a template language that renders the pages your application19  serves.20* `MarkupSafe`_ comes with Jinja. It escapes untrusted input when rendering21  templates to avoid injection attacks.22* `ItsDangerous`_ securely signs data to ensure its integrity. This is used23  to protect Flask's session cookie.24* `Click`_ is a framework for writing command line applications. It provides25  the ``flask`` command and allows adding custom management commands.26* `Blinker`_ provides support for :doc:`signals`.2728.. _Werkzeug: https://palletsprojects.com/p/werkzeug/29.. _Jinja: https://palletsprojects.com/p/jinja/30.. _MarkupSafe: https://palletsprojects.com/p/markupsafe/31.. _ItsDangerous: https://palletsprojects.com/p/itsdangerous/32.. _Click: https://palletsprojects.com/p/click/33.. _Blinker: https://blinker.readthedocs.io/343536Optional dependencies37~~~~~~~~~~~~~~~~~~~~~3839These distributions will not be installed automatically. Flask will detect and40use them if you install them.4142* `python-dotenv`_ enables support for :ref:`dotenv` when running ``flask``43  commands.44* `Watchdog`_ provides a faster, more efficient reloader for the development45  server.4647.. _python-dotenv: https://github.com/theskumar/python-dotenv#readme48.. _watchdog: https://pythonhosted.org/watchdog/495051greenlet52~~~~~~~~5354You may choose to use gevent or eventlet with your application. In this55case, greenlet>=1.0 is required. When using PyPy, PyPy>=7.3.7 is56required.5758These are not minimum supported versions, they only indicate the first59versions that added necessary features. You should use the latest60versions of each.616263Virtual environments64--------------------6566Use a virtual environment to manage the dependencies for your project, both in67development and in production.6869What problem does a virtual environment solve? The more Python projects you70have, the more likely it is that you need to work with different versions of71Python libraries, or even Python itself. Newer versions of libraries for one72project can break compatibility in another project.7374Virtual environments are independent groups of Python libraries, one for each75project. Packages installed for one project will not affect other projects or76the operating system's packages.7778Python comes bundled with the :mod:`venv` module to create virtual79environments.808182.. _install-create-env:8384Create an environment85~~~~~~~~~~~~~~~~~~~~~8687Create a project folder and a :file:`.venv` folder within:8889.. tabs::9091   .. group-tab:: macOS/Linux9293      .. code-block:: text9495         $ mkdir myproject96         $ cd myproject97         $ python3 -m venv .venv9899   .. group-tab:: Windows100101      .. code-block:: text102103         > mkdir myproject104         > cd myproject105         > py -3 -m venv .venv106107108.. _install-activate-env:109110Activate the environment111~~~~~~~~~~~~~~~~~~~~~~~~112113Before you work on your project, activate the corresponding environment:114115.. tabs::116117   .. group-tab:: macOS/Linux118119      .. code-block:: text120121         $ . .venv/bin/activate122123   .. group-tab:: Windows124125      .. code-block:: text126127         > .venv\Scripts\activate128129Your shell prompt will change to show the name of the activated130environment.131132133Install Flask134-------------135136Within the activated environment, use the following command to install137Flask:138139.. code-block:: sh140141    $ pip install Flask142143Flask is now installed. Check out the :doc:`/quickstart` or go to the144:doc:`Documentation Overview </index>`.