How To Successfully Install Django On Windows

Django is the popular python web framework. It can be used in any operating system includes Windows, Linux etc. But when i install Django on Windows, i meet some problems which confuse me some time. I write this article to tell me and others how to resolve those issue when you install django on Windows.

1. Install Django On Windows.

Before you can install Django, you need make sure that you have installed Python3 and PIP3 on your Windows first. Please read article How To Install Python/Pip On Windows if you do not. After confirmation, you can follow below steps to install Django.

  1. Open a terminal and run command pip3 install django.
  2. But you may get below error message which said the access is denied, you do not have permission.
    Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: ‘c:\\program files (x86)\\python37-32\\lib\\site-packages\\pip-10.0.1.dist-info\\entry_points.txt’ Consider using the `–user` option or check the permissions.
  3. Do not worry, as the error message said, you just need to add –user option at the end of the command. So run below command again, then you can install python django succefully.
    pip3 install django –user

2. Run Django  Admin To Create First Django Project.

Now you have installed django on Windows successfully. The next step, we will run django-admin command to create our first django project.

But when you input django-admin in the dos window, it will tell you that ‘django-admin’ is not recognized as an internal or external command, operable program or batch file. This is because you have not add the django-admin command in Windows PATH system environment variable value.

READ :   Python Login Register JSON Example

2.1 Add django-admin.exe in Windows PATH system variable value.

  1. First run pip3 show django command in terminal to get django information such as installed directory like below.
    C:\Users\zhaosong>pip3 show django
    Name: Django
    Version: 2.1.5
    Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
    Home-page: https://www.djangoproject.com/
    Author: Django Software Foundation
    Author-email: [email protected]
    License: BSD
    Location: c:\users\zhaosong\appdata\roaming\python\python37\site-packages
    Requires: pytz
    Required-by:
  2. The django-admin.exe command is not saved in the above location directory. It is saved in the same level directory of above location that is C:\Users\zhaosong\AppData\Roaming\Python\Python37\Scripts, add this directory in Windows PATH system environment variable value. Please refer article How To Set Java Environment Viriable JAVA_HOME, CLASSPATH, PATH.
  3. Now open another dos window to make above PATH settings take effect, and run below command in the dos window to create your first django project.
    django-admin startproject DjangoHelloWorld

    django hello world project

(Visited 20 times, 2 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.