Sutthirak

Jul 7, 2016

There are some steps before build a Python application in your Windows. Let's start!


1. install Git

I thought almost everyone uses Git as a primary source code management. For Windows. You can download the installation file directly from their website:
https://git-scm.com/download/win.
With this tutorial, I will do everything in Git-Bash :)


2. install Python

The step is quite important. You can not run your application if you don't have Python interpreter. Download and install it via
https://www.python.org/downloads/.
This process will automatically install pip (the name of Python package management system)for you.


3. install virtualenv

To differentiate a version of dependencies which you want to use in each of your application. Installing virtualenv is a good idea. You can install it from pip with this command.
$ pip install virtualenv
When the installation is successful. It will generate the Envs directory in your home. (~/Envs)


4. create and activate your environment.

Let's say I would like to set up an environment for creating a Django application. I will use this command.
$ virtualenv ~/Envs/djangodev
This command will create environment name djangodev and put necessary files into that directory. But it's not finished yet. You have to activate it with this command.
$ source ~/Envs/djangodev/Scripts/activate
it will show the environment name in your Git-Bash similar like this
(djangodev)
Me@Com MINGW64 ~/Envs/djangodev


5. create requirements.txt and install

In this case, I would like to specify all of the application dependencies with pip. For example, I want to use Django 1.9.7 version. I will specify in requirements.txt with command.
$ echo 'Django==1.9.7' >> requirements.txt
and then use pip to install it via
$ pip install -r requirements.txt
Django 1.9.7 is ready to use!
$ python -m django --version
1.9.7