Python and Django Installation on Windows Environment

mongodb-installation-cover

It’s been along time i’m not writing tutorial on my blog, since i’m struggling to learn some languages those are Python and Ruby, and also i’ve learned some frameworks of them those are Django and Rails. Why?? i have two reasons to answer that question, first i’ve assigned to do self learning on my office, and the second one i’m curious on that. This time i’m talking about Python, I think Python language has a good code structure because we have to careful in writing Python code, in fact the indentation take an effect to the interpreter, our codes will be compiled error if we are wrong to set the indentation. But the advantage is our codes will be structured and it will be easier to read. It will be easy to write Python codes if you have a good IDE that has formater feature for python. But now, i’m going to give you the way to install Python and Django on your windows machine. Django is one of the framework that using Python as a base language and I think Django is the most popular one than the others.

Prerequisite : –

Python Installation :

Now, Lets get the ball rolling :

1st. First, we have to download the latest Python Installer (as per may 2015 the version is 3.4.3).

2nd. Click the installer, and set to the default directory (C:\Python34) and wait until the progress is done.

Add Path on Windows Environment Variables :

1st. Right click on My Computer.
2nd. Click Advanced system settings.
3th. Click Environment Variables button.
4th. Click PATH on Variable column, then append this path.

note : adjust the version and take a look the delimiter “;”.

Check everything is running well :

1st. Open the windows command prompt.

2nd. Type “Python” on your command prompt, if you are seeing  image below that means python is already installed on your windows.

python-command-line

note : the path is working when you open the command prompt after you already set the path, don’t use your recent command prompt before you set the path.

Django Installation :

1st. First, we have to download the latest Django Framework (as per may 2015 the version is 1.8.1).

2nd. After the file has been downloaded, then extract to C:\Django.

3th. Open command prompt on that directory then type python setup.ph install and wait until the progress is done.

4th. Type python again, then type import django (if there is no message appears that mean Django has been installed properly).

python-import-django

5th. You can quit from python command line using Ctrl+z then enter or type exit() then enter.

Create Django Project :

To ensure the python and django is already working properly, let’s create the Django project.

1st. Create folder under directory C:\Django, you can name it C:\Django\projectsC:\Django\works, or anything you want.

2nd. Set command prompt to your projects directory, to create Django site you only need to type django-admin startproject [project name], (as for example django-admin startproject newsite).

3th. Now, your newsite project has been generated on your projects directory and named as you decide.

python-django-folder-newsite

4th. Let’s running the server, ensure your command prompt has been set on your project folder.

5th. To run Django server you only need to type python manage.py runserver (the default port is 8000), if you want to run server on another port you only need to type python manage.py runserver 8087 and the server is running on port 8087.

6th. Open browser and go to url http://localhost:8087 or http://127.0.0.1:8087.

django-default-project

Congratulation, now you are having Python and Django on your windows machine and you know how to create project and how to run the Django server. I hope next time, i can write the tutorial using Django Framework.

 

FatkhanFauzi About FatkhanFauzi

A passionate software engineer who wants to share anything that he learns and some of his life experiences. Want to know more about him? see Fatkhan Fauzi Profile


2 Comments

  • Reply MM |

    Please don’t underestimate the strugles with Python on Win. I run in a lot of troubles esp. with modules that rely on native libs (e.g. geolocation stuff, numpy, …). It’s still a mess with 32/64bit borders and no native compiler suite -.-

    • Reply FatkhanFauzi |

      Hahaha.. Yup i know how’s difficult on that; but i know if someone loves python they will do anything on that, no matter what’s the environment. 🙂
      Furthermore, most of the people that works in my office are using Linux to develop on python.
      Good Luck for that Sir. 🙂

So, what do you think ?

Leave a Reply

%d bloggers like this: