Skip to content
Myr

installation.rst

This file

Path

docs/installation.rst

145 lines · 3.7 KiB

Last changed by

Merge pull request #4335 from pallets/drop-python-3.6David Lordbefore adoptionea93a52

History of this file

Take it

1Installation2============345Python Version6--------------78We recommend using the latest version of Python. Flask supports Python93.7 and newer.101112Dependencies13------------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: 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/333435Optional dependencies36~~~~~~~~~~~~~~~~~~~~~3738These distributions will not be installed automatically. Flask will detect and39use them if you install them.4041* `Blinker`_ provides support for :doc:`signals`.42* `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.. _Blinker: https://pythonhosted.org/blinker/48.. _python-dotenv: https://github.com/theskumar/python-dotenv#readme49.. _watchdog: https://pythonhosted.org/watchdog/505152greenlet53~~~~~~~~5455You may choose to use gevent or eventlet with your application. In this56case, greenlet>=1.0 is required. When using PyPy, PyPy>=7.3.7 is57required.5859These are not minimum supported versions, they only indicate the first60versions that added necessary features. You should use the latest61versions of each.626364Virtual environments65--------------------6667Use a virtual environment to manage the dependencies for your project, both in68development and in production.6970What problem does a virtual environment solve? The more Python projects you71have, the more likely it is that you need to work with different versions of72Python libraries, or even Python itself. Newer versions of libraries for one73project can break compatibility in another project.7475Virtual environments are independent groups of Python libraries, one for each76project. Packages installed for one project will not affect other projects or77the operating system's packages.7879Python comes bundled with the :mod:`venv` module to create virtual80environments.818283.. _install-create-env:8485Create an environment86~~~~~~~~~~~~~~~~~~~~~8788Create a project folder and a :file:`venv` folder within:8990.. tabs::9192   .. group-tab:: macOS/Linux9394      .. code-block:: text9596         $ mkdir myproject97         $ cd myproject98         $ python3 -m venv venv99100   .. group-tab:: Windows101102      .. code-block:: text103104         > mkdir myproject105         > cd myproject106         > py -3 -m venv venv107108109.. _install-activate-env:110111Activate the environment112~~~~~~~~~~~~~~~~~~~~~~~~113114Before you work on your project, activate the corresponding environment:115116.. tabs::117118   .. group-tab:: macOS/Linux119120      .. code-block:: text121122         $ . venv/bin/activate123124   .. group-tab:: Windows125126      .. code-block:: text127128         > venv\Scripts\activate129130Your shell prompt will change to show the name of the activated131environment.132133134Install Flask135-------------136137Within the activated environment, use the following command to install138Flask:139140.. code-block:: sh141142    $ pip install Flask143144Flask is now installed. Check out the :doc:`/quickstart` or go to the145:doc:`Documentation Overview </index>`.