[3.0.x] Fixed #31628 -- Updated Windows install guide to recommend venv.
Backport of 922ff51f5a
from master
This commit is contained in:
parent
11fc1cac9e
commit
066076afaa
|
@ -5,11 +5,10 @@ How to install Django on Windows
|
||||||
.. highlight:: doscon
|
.. highlight:: doscon
|
||||||
|
|
||||||
This document will guide you through installing Python 3.7 and Django on
|
This document will guide you through installing Python 3.7 and Django on
|
||||||
Windows. It also provides instructions for installing `virtualenv`_ and
|
Windows. It also provides instructions for setting up a virtual environment,
|
||||||
`virtualenvwrapper`_, which make it easier to work on Python projects. This is
|
which makes it easier to work on Python projects. This is meant as a beginner's
|
||||||
meant as a beginner's guide for users working on Django projects and does not
|
guide for users working on Django projects and does not reflect how Django
|
||||||
reflect how Django should be installed when developing patches for Django
|
should be installed when developing patches for Django itself.
|
||||||
itself.
|
|
||||||
|
|
||||||
The steps in this guide have been tested with Windows 7, 8, and 10. In other
|
The steps in this guide have been tested with Windows 7, 8, and 10. In other
|
||||||
versions, the steps would be similar. You will need to be familiar with using
|
versions, the steps would be similar. You will need to be familiar with using
|
||||||
|
@ -49,30 +48,34 @@ get-pip.py`` instructions.
|
||||||
|
|
||||||
.. _pip: https://pypi.org/project/pip/
|
.. _pip: https://pypi.org/project/pip/
|
||||||
|
|
||||||
.. _virtualenvwrapper-win:
|
.. _virtualenvironment:
|
||||||
|
|
||||||
Install ``virtualenv`` and ``virtualenvwrapper``
|
Setting up a virtual environment
|
||||||
================================================
|
================================
|
||||||
|
|
||||||
`virtualenv`_ and `virtualenvwrapper`_ provide a dedicated environment for
|
It is best practice to provide a dedicated environment for each Django project
|
||||||
each Django project you create. While not mandatory, this is considered a best
|
you create. There are many options to manage environments and packages within
|
||||||
practice and will save you time in the future when you're ready to deploy your
|
the Python ecosystem, some of which are recommended in the `Python
|
||||||
project. To do this, run::
|
documentation <https://packaging.python.org/guides/tool-recommendations/>`_.
|
||||||
|
Python itself comes with `venv`_ for managing environments which we will use
|
||||||
|
for this guide.
|
||||||
|
|
||||||
...\> py -m pip install virtualenvwrapper-win
|
To create a virtual environment for your project, open a new command prompt,
|
||||||
|
navigate to the folder where you want to create your project and then enter the
|
||||||
|
following::
|
||||||
|
|
||||||
Then create a virtual environment for your project::
|
...\> py -m venv project-name
|
||||||
|
|
||||||
...\> mkvirtualenv myproject
|
This will create a folder called 'project-name' if it does not already exist
|
||||||
|
and setup the virtual environment. To activate the environment, run::
|
||||||
|
|
||||||
The virtual environment will be activated automatically and you'll see
|
...\> project-name\Scripts\activate.bat
|
||||||
"(myproject)" next to the command prompt to designate that. If you start a new
|
|
||||||
command prompt, you'll need to activate the environment again using::
|
|
||||||
|
|
||||||
...\> workon myproject
|
The virtual environment will be activated and you'll see "(project-name)" next
|
||||||
|
to the command prompt to designate that. Each time you start a new command
|
||||||
|
prompt, you'll need to activate the environment again.
|
||||||
|
|
||||||
.. _virtualenv: https://pypi.org/project/virtualenv/
|
.. _venv: https://docs.python.org/3/tutorial/venv.html
|
||||||
.. _virtualenvwrapper: https://pypi.org/project/virtualenvwrapper-win/
|
|
||||||
|
|
||||||
Install Django
|
Install Django
|
||||||
==============
|
==============
|
||||||
|
|
|
@ -163,13 +163,6 @@ more convenient.
|
||||||
|
|
||||||
...\> %HOMEPATH%\.virtualenvs\djangodev\Scripts\activate.bat
|
...\> %HOMEPATH%\.virtualenvs\djangodev\Scripts\activate.bat
|
||||||
|
|
||||||
or you can install :ref:`a Windows version of virtualenvwrapper
|
|
||||||
<virtualenvwrapper-win>` and then use:
|
|
||||||
|
|
||||||
.. code-block:: doscon
|
|
||||||
|
|
||||||
...\> workon djangodev
|
|
||||||
|
|
||||||
__ https://virtualenvwrapper.readthedocs.io/en/latest/
|
__ https://virtualenvwrapper.readthedocs.io/en/latest/
|
||||||
|
|
||||||
The name of the currently activated virtual environment is displayed on the
|
The name of the currently activated virtual environment is displayed on the
|
||||||
|
|
Loading…
Reference in New Issue