<< Back to Blog

A Django Project: Development Environment (Windows 10)

Updated on May 11, 2019

It is easy to find plenty of examples/tutorials for developing with Python/Django in Linux and OSX but when it comes to developing on Windows there are many options. Some of these options include using tools like Cygwin, Vagrant, or most recently Windows 10 has provided a new feature called the Linux Subsystem, also known as Bash on Windows. I have used each of these solutions but found them to be easy to complicate or just a lot to keep track of. Finally, I decided to install Python on Windows 10 along with pip, virtualenv, and virtualenvwrapper-win. If the aforementioned tools are designed to virtualize your Python project environment why add another layer on top of it (as you would with Vagrant or the Linux subsystem)?

 

Before we get started it helps to have a basic understanding of each component’s role:

Python – Our programming language. In this case I went with version 3.7.3.

pip – a Python package-manager. This allows you to easily install/uninstall/update and otherwise manage packages used for Python.

virtualenv – this allows you to create a self-contained environment to develop your Python project in. You end up with a separate directory for all of the packages and dependencies to build your project. It will even allow you to run different versions of Python for each project.

virtualenvwrapper-win – based on virtualenvwrapper, this  is the Windows version. This set of extensions helps with managing multiple virtualenv environments by providing you with additional tools/commands.

Django – the Django web framework that I will be using to build my project site/back-end for my mobile apps.

 

Getting Started (installing everything)

  1. Download and install the latest version of Python 3 (as recommended by the Django team).
    a) I chose the downloadable executable.  Important note: make sure on the first screen of the installer you choose to “Add Python 3.* to PATH.” If you skip ahead and miss this, just uninstall and reinstall. That checkbox basically allows you to run Python from the command line without having to type out the entire path to it (for e.g.: you can type “python3” instead of: “C:\python3\python” to run Python. For the rest of the steps I checked everything except for “Install for all users” and “Pre-compile standard library.”
    b) If you have an older 3.x.x version can simply go to https://www.python.org/downloads/ to find the latest release and the installer will give you an option to update your existing install.
  2. Install/update pip. From the official pip site: “pip is already installed if you’re using Python 2 >=2.7.16 or Python 3 >=3.7 binaries downloaded from python.org, but you’ll need to upgrade pip.”
    a) to update pip in our case start a Windows Command Prompt as administrator. Click on the search box near the Windows 10 start button or click on the start button and begin typing ‘cmd’ then right-click and choose “Run as Administrator.”
    b) in the new command prompt type ‘pip install -U pip’ and press ‘enter.’
    c) I ended up with the following result: “Requirement already up-to-date: pip in c:\users\charleskh\appdata\local\programs\python\python35\lib\site-packages.”
  3. Next we need to install virtualenv.
    a) in the same command prompt (if you closed it follow step 2a to run a command prompt as administrator) type ‘pip install virtualenv’ and press ‘enter.’
    b) if you already have virtualenv installed you can make sure it is up-to-date by typing ‘pip install -U virtualenv’ and then press ‘enter.’
  4. Finally let’s install virtualenvwrapper-win.
    a) as before in a command prompt as administrator type ‘pip install virtualenvwrapper-win’ and press ‘enter.’

 

In the next post of this series I will go through the process of starting up a project using virtualenv and installing Django.