How to install Django on Windows

    The steps in this guide have been tested with Windows 10. In other versions, the steps would be similar. You will need to be familiar with using the Windows command prompt.

    Django is a Python web framework, thus requiring Python to be installed on your machine. At the time of writing, Python 3.8 is the latest version.

    To install Python on your machine go to https://www.python.org/downloads/. The website should offer you a download button for the latest Python version. Download the executable installer and run it. Check the boxes next to “Install launcher for all users (recommended)” then click “Install Now”.

    After installation, open the command prompt and check that the Python version matches the version you installed by executing:

    See also

    For more details, see documentation.

    About pip

    It is best practice to provide a dedicated environment for each Django project you create. There are many options to manage environments and packages within the Python ecosystem, some of which are recommended in the . Python itself comes with venv for managing environments which we will use for this guide.

    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:

    1. ...\> py -m venv project-name

    This will create a folder called ‘project-name’ if it does not already exist and set up the virtual environment. To activate the environment, run:

    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.

    Install Django

    Django can be installed easily using pip within your virtual environment.

    In the command prompt, ensure your virtual environment is active, and execute the following command:

      After the installation has completed, you can verify your Django installation by executing django-admin --version in the command prompt.

      See Get your database running for information on database installation with Django.

      A quality-of-life feature adds colored (rather than monochrome) output to the terminal. In modern terminals this should work for both CMD and PowerShell. If for some reason this needs to be disabled, set the environmental variable to nocolor.

      On older Windows versions, or legacy terminals, colorama must be installed to enable syntax coloring:

      See for more information on color settings.

      Common pitfalls

      • If django-admin only displays the help text no matter what arguments 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.

        1. ...\> set http_proxy=http://username:password@proxyserver:proxyport
      • In general, Django assumes that UTF-8 encoding is used for I/O. This may cause problems if your system is set to use a different encoding. Recent versions of Python allow setting the environment variable in order to force a UTF-8 encoding. Windows 10 also provides a system-wide setting by checking in Language ‣ Administrative Language Settings ‣ Change system locale in system settings.