Looking for a new apartment in your city? Is it election day and you want to remind people to get out and vote? Want to poll residents for the best restaurant in their neighborhood?

In this blog post, we’ll build a messaging application where messages are broadcast to recipients based on the city reported by their browser location. Having everyone in your city join together in a chat application may seem crazy, but buckle up, because we’re going to give it a try. By combining Python, Django, Twilio Programmable Chat and the Google Maps API we’ll take our best shot at making it easier to find an apartment, remind your neighbors to vote or poll your fellow city residents.

Tools We’ll Need

Before we dive into building our neighborhood-based chat application, let’s take a look at the tools we’ll be using throughout this blog post.

Don’t worry about installing these tools just yet – we’ll handle that in the sections below as we go through this tutorial. If you want to see the completed code from this blog post at any time check out the GitHub repository with the finished project. Before we start writing our code though let’s walk through preparing our Python environment for development.

Python Environment Setup

Our prep work starts with getting our Python development environment ready to build our neighborhood-based chat application. In this section we’ll handle the following steps to make sure you’re ready to run the code:

Check that Python is installed correctly Set up and activate a new virtualenv Install required Python dependencies into our virtualenv using pip

Setup Step 1: Check the Python installation

If you’re on Mac OS X or Linux, you’ve already got Python installed on your system. Check the version by going into the terminal and typing python —version . You’ll see the precise version number, something like Python 2.7.6. If you’re on Python 2.6 or greater, you’re good to go.

For Windows, make sure you download and install the Python .exe installation package. Either Python 2 or 3 is fine. If you want further information about the 2 versus 3 version debate, there’s plenty more information written by experienced Python developers on the topic. My recommendation is to use Python 3.5 unless you have a pressing reason to use an earlier version, because the Python community is now migrating to Python 3.

Once Python is installed on your system and you can run it with the python command, we’re ready to set up a virtualenv.

Setup Step 2: Set up a new virtualenv and activate it