windows.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ================================
  2. How to install Django on Windows
  3. ================================
  4. .. highlight:: doscon
  5. This document will guide you through installing Python 3.7 and Django on
  6. Windows. It also provides instructions for installing `virtualenv`_ and
  7. `virtualenvwrapper`_, which make it easier to work on Python projects. This is
  8. meant as a beginner's guide for users working on Django projects and does not
  9. reflect how Django should be installed when developing patches for Django
  10. itself.
  11. The steps in this guide have been tested with Windows 7, 8, and 10. In other
  12. versions, the steps would be similar. You will need to be familiar with using
  13. the Windows command prompt.
  14. Install Python
  15. ==============
  16. Django is a Python web framework, thus requiring Python to be installed on your
  17. machine. At the time of writing, Python 3.7 is the latest version.
  18. To install Python on your machine go to https://python.org/downloads/. The
  19. website should offer you a download button for the latest Python version.
  20. Download the executable installer and run it. Check the boxes next to ``Install
  21. launcher for all users (recommended)`` and ``Add Python 3.7 to PATH`` then
  22. click ``Install Now``.
  23. After installation, open the command prompt and check that the Python version
  24. matches the version you installed by executing::
  25. ...\> py --version
  26. .. seealso::
  27. For more details, see :doc:`python:using/windows` documentation.
  28. About ``pip``
  29. =============
  30. `pip`_ is a package manage for Python. It makes installing and uninstalling
  31. Python packages (such as Django!) very easy. For the rest of the installation,
  32. we'll use ``pip`` to install Python packages from the command line.
  33. To install pip on your machine, go to
  34. https://pip.pypa.io/en/latest/installing/, and follow the ``Installing with
  35. get-pip.py`` instructions.
  36. .. _pip: https://pypi.org/project/pip/
  37. .. _virtualenvwrapper-win:
  38. Install ``virtualenv`` and ``virtualenvwrapper``
  39. ================================================
  40. `virtualenv`_ and `virtualenvwrapper`_ provide a dedicated environment for
  41. each Django project you create. While not mandatory, this is considered a best
  42. practice and will save you time in the future when you're ready to deploy your
  43. project. To do this, run::
  44. ...\> py -m pip install virtualenvwrapper-win
  45. Then create a virtual environment for your project::
  46. ...\> mkvirtualenv myproject
  47. The virtual environment will be activated automatically and you'll see
  48. "(myproject)" next to the command prompt to designate that. If you start a new
  49. command prompt, you'll need to activate the environment again using::
  50. ...\> workon myproject
  51. .. _virtualenv: https://pypi.org/project/virtualenv/
  52. .. _virtualenvwrapper: https://pypi.org/project/virtualenvwrapper-win/
  53. Install Django
  54. ==============
  55. Django can be installed easily using ``pip`` within your virtual environment.
  56. In the command prompt, ensure your virtual environment is active, and execute
  57. the following command::
  58. ...\> py -m pip install Django
  59. This will download and install the latest Django release.
  60. After the installation has completed, you can verify your Django installation
  61. by executing ``django-admin --version`` in the command prompt.
  62. See :ref:`database-installation` for information on database installation
  63. with Django.
  64. Common pitfalls
  65. ===============
  66. * If ``django-admin`` only displays the help text no matter what arguments
  67. it is given, there is probably a problem with the file association in
  68. Windows. Check if there is more than one environment variable set for
  69. running Python scripts in ``PATH``. This usually occurs when there is more
  70. than one Python version installed.
  71. * If you are connecting to the internet behind a proxy, there might be problems
  72. in running the command ``py -m pip install Django``. Set the environment
  73. variables for proxy configuration in the command prompt as follows::
  74. ...\> set http_proxy=http://username:password@proxyserver:proxyport
  75. ...\> set https_proxy=https://username:password@proxyserver:proxyport