2014-03-19 19:38:12 +01:00
|
|
|
================================
|
|
|
|
How to install Django on Windows
|
|
|
|
================================
|
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
.. highlight:: doscon
|
|
|
|
|
2019-01-18 16:04:29 +01:00
|
|
|
This document will guide you through installing Python 3.7 and Django on
|
2015-10-01 16:57:12 +02:00
|
|
|
Windows. It also provides instructions for installing `virtualenv`_ and
|
|
|
|
`virtualenvwrapper`_, which make it easier to work on Python projects. This is
|
|
|
|
meant as a beginner's guide for users working on Django projects and does not
|
|
|
|
reflect how Django should be installed when developing patches for Django
|
|
|
|
itself.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2015-10-01 16:57:12 +02:00
|
|
|
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
|
|
|
|
the Windows command prompt.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
|
|
|
Install Python
|
|
|
|
==============
|
|
|
|
|
|
|
|
Django is a Python web framework, thus requiring Python to be installed on your
|
2019-01-18 16:04:29 +01:00
|
|
|
machine. At the time of writing, Python 3.7 is the latest version.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2016-01-10 18:16:28 +01:00
|
|
|
To install Python on your machine go to https://python.org/downloads/. The
|
|
|
|
website should offer you a download button for the latest Python version.
|
2019-04-19 21:15:38 +02:00
|
|
|
Download the executable installer and run it. Check the boxes next to ``Install
|
|
|
|
launcher for all users (recommended)`` and ``Add Python 3.7 to PATH`` then
|
|
|
|
click ``Install Now``.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2015-10-01 16:57:12 +02:00
|
|
|
After installation, open the command prompt and check that the Python version
|
|
|
|
matches the version you installed by executing::
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> py --version
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
For more details, see :doc:`python:using/windows` documentation.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2016-01-24 22:26:11 +01:00
|
|
|
About ``pip``
|
|
|
|
=============
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2015-10-01 16:57:12 +02:00
|
|
|
`pip`_ is a package manage for Python. It makes installing and uninstalling
|
|
|
|
Python packages (such as Django!) very easy. For the rest of the installation,
|
|
|
|
we'll use ``pip`` to install Python packages from the command line.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2016-04-16 12:15:18 +02:00
|
|
|
To install pip on your machine, go to
|
|
|
|
https://pip.pypa.io/en/latest/installing/, and follow the ``Installing with
|
|
|
|
get-pip.py`` instructions.
|
|
|
|
|
2018-04-18 00:19:29 +02:00
|
|
|
.. _pip: https://pypi.org/project/pip/
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
.. _virtualenvwrapper-win:
|
|
|
|
|
2015-10-01 16:57:12 +02:00
|
|
|
Install ``virtualenv`` and ``virtualenvwrapper``
|
|
|
|
================================================
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2015-10-01 16:57:12 +02:00
|
|
|
`virtualenv`_ and `virtualenvwrapper`_ provide a dedicated environment for
|
|
|
|
each Django project you create. While not mandatory, this is considered a best
|
|
|
|
practice and will save you time in the future when you're ready to deploy your
|
2019-06-17 16:54:55 +02:00
|
|
|
project. To do this, run::
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> py -m pip install virtualenvwrapper-win
|
2015-10-01 16:57:12 +02:00
|
|
|
|
|
|
|
Then create a virtual environment for your project::
|
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> mkvirtualenv myproject
|
2015-10-01 16:57:12 +02:00
|
|
|
|
|
|
|
The virtual environment will be activated automatically and you'll see
|
|
|
|
"(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::
|
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> workon myproject
|
2015-10-01 16:57:12 +02:00
|
|
|
|
2018-04-18 00:19:29 +02:00
|
|
|
.. _virtualenv: https://pypi.org/project/virtualenv/
|
|
|
|
.. _virtualenvwrapper: https://pypi.org/project/virtualenvwrapper-win/
|
2014-03-19 19:38:12 +01:00
|
|
|
|
|
|
|
Install Django
|
|
|
|
==============
|
|
|
|
|
2016-04-16 12:15:18 +02:00
|
|
|
Django can be installed easily using ``pip`` within your virtual environment.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2016-04-16 12:15:18 +02:00
|
|
|
In the command prompt, ensure your virtual environment is active, and execute
|
|
|
|
the following command::
|
2015-10-01 16:57:12 +02:00
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> py -m pip install Django
|
2015-10-01 16:57:12 +02:00
|
|
|
|
|
|
|
This will download and install the latest Django release.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
|
|
|
After the installation has completed, you can verify your Django installation
|
2014-07-26 13:21:52 +02:00
|
|
|
by executing ``django-admin --version`` in the command prompt.
|
2014-03-19 19:38:12 +01:00
|
|
|
|
|
|
|
See :ref:`database-installation` for information on database installation
|
|
|
|
with Django.
|
|
|
|
|
|
|
|
Common pitfalls
|
|
|
|
===============
|
|
|
|
|
2014-07-26 13:21:52 +02:00
|
|
|
* If ``django-admin`` only displays the help text no matter what arguments
|
2014-03-19 19:38:12 +01:00
|
|
|
it is given, there is probably a problem with the file association in
|
|
|
|
Windows. Check if there is more than one environment variable set for
|
|
|
|
running Python scripts in ``PATH``. This usually occurs when there is more
|
|
|
|
than one Python version installed.
|
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
* If you are connecting to the internet behind a proxy, there might be problems
|
|
|
|
in running the command ``py -m pip install Django``. Set the environment
|
2019-04-14 17:02:36 +02:00
|
|
|
variables for proxy configuration in the command prompt as follows::
|
2014-03-19 19:38:12 +01:00
|
|
|
|
2019-04-19 21:15:38 +02:00
|
|
|
...\> set http_proxy=http://username:password@proxyserver:proxyport
|
|
|
|
...\> set https_proxy=https://username:password@proxyserver:proxyport
|