windows.txt 3.7 KB

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