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 fileTake 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 back1.. _installation:23Installation4============56Python Version7--------------8Merge pull request #2555 from pallets/deprecate-26-33David Lordbefore adoption05e3840
lines 9–10why, one step back9We recommend using the latest version of Python 3. Flask supports Python 3.410and newer, Python 2.7, and PyPy.Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 11–29why, one step back1112Dependencies13------------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 back30.. _MarkupSafe: https://pypi.org/project/MarkupSafe/Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 31–45why, one step back31.. _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 back46* `Watchdog`_ provides a faster, more efficient reloader for the development47 server.Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 48–51why, one step back4849.. _Blinker: https://pythonhosted.org/blinker/50.. _SimpleJSON: https://simplejson.readthedocs.io/51.. _python-dotenv: https://github.com/theskumar/python-dotenv#readmeMerge pull request #2490 from davidism/cli-reviewDavid Lordbefore adoption0932d8f
line 52why, one step back52.. _watchdog: https://pythonhosted.org/watchdog/Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 53–83why, one step back5354Virtual 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:: sh83Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
lines 84–86why, one step back84 $ mkdir myproject85 $ cd myproject86 $ python3 -m venv venvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 87–91why, one step back8788On Windows:8990.. code-block:: bat91Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 92why, one step back92 $ py -3 -m venv venvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 93why, one step back93Merge branch '1.0-maintenance'David Lordbefore adoption3b45b82
lines 94–95why, one step back94If you needed to install virtualenv because you are using Python 2, use95the following command instead:Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 96–98why, one step back9697.. code-block:: sh98Merge branch '1.0-maintenance'David Lordbefore adoption3b45b82
line 99why, one step back99 $ python2 -m virtualenv venvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 100–104why, one step back100101On Windows:102103.. code-block:: bat104Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 105why, one step back105 > \Python27\Scripts\virtualenv.exe venvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 106why, one step back106Merge pull request #2676 from davidism/tutorialDavid Lordbefore adoptionc3e2ff2
lines 107–108why, one step back107.. _install-activate-env:108Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 109–115why, one step back109Activate the environment110~~~~~~~~~~~~~~~~~~~~~~~~111112Before you work on your project, activate the corresponding environment:113114.. code-block:: sh115Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 116why, one step back116 $ . venv/bin/activateMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 117–121why, one step back117118On Windows:119120.. code-block:: bat121Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 122why, one step back122 > venv\Scripts\activateMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 123–132why, one step back123124Your 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:: sh132Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 133why, one step back133 $ pip install FlaskMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 134why, one step back134Merge branch '1.0-maintenance'ThiefMasterbefore adoption161c436
lines 135–137why, one step back135Flask is now installed. Check out the :doc:`/quickstart` or go to the136:doc:`Documentation Overview </index>`.137Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 138–145why, one step back138Living on the edge139~~~~~~~~~~~~~~~~~~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:: sh145Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 146why, one step back146 $ pip install -U https://github.com/pallets/flask/archive/master.tar.gzMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 147–160why, one step back147148.. _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, UbuntuAdd prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 161why, one step back161 $ sudo apt-get install python-virtualenvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 162–163why, one step back162163 # CentOS, FedoraAdd prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 164why, one step back164 $ sudo yum install python-virtualenvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 165–166why, one step back165166 # ArchAdd prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
line 167why, one step back167 $ sudo pacman -S python-virtualenvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 168–172why, one step back168169If you are on Mac OS X or Windows, download `get-pip.py`_, then:170171.. code-block:: sh172Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
lines 173–174why, one step back173 $ sudo python2 Downloads/get-pip.py174 $ sudo python2 -m pip install virtualenvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 175–179why, one step back175176On Windows, as an administrator:177178.. code-block:: bat179Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6
lines 180–181why, one step back180 > \Python27\python.exe Downloads\get-pip.py181 > \Python27\python.exe -m pip install virtualenvMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 182why, one step back182Merge branch '1.0-maintenance'ThiefMasterbefore adoption161c436
line 183why, one step back183Now you can return above and :ref:`install-create-env`.Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 184–186why, one step back184185.. _virtualenv: https://virtualenv.pypa.io/186.. _get-pip.py: https://bootstrap.pypa.io/get-pip.py