Skip to content

Preparing the environment

Roberto Prevato edited this page Nov 8, 2016 · 7 revisions

This page describes how to set up the environment, to run the aiohttp three project template.

Python

Unless already installed, it is necessary to install Python >= 3.4.2.

Preparing the Python environment

To prepare the Python development environment, it is necessary to:

  • create a Python virtual environment
  • satisfy some system requirements
  • install the required packages

Note for beginners:

A Python virtual environment is a local interpreter that allows to install dependencies without polluting the global Python interpreter. There are different ways to create virtual environments (virtualenv; -m venv) and to install packages (pip install; easy_install), which may be confusing at the beginning. For further information about virtualenv and pip, the lecture of this detailed article is recommended: A non-magical introduction to Pip and Virtualenv for Python beginners. This article describes the approach using virtualenv. The other approach, using the venv module, is similar and presents only few differences. pip stands for "Python installer Po" and is the commonly used package manager for Python. Installing dependencies using pip is straightforward and fast.

System requirements

Although installing Python is easy, third party packages sometimes have extra requirements that are not obvious. This section lists the Windows and Linux system requirements to run the project template.

Windows

  • pycrypto requires C++ Tools for Windows

Ubuntu 16.04

  • the Python driver for PostreSQL fails during installation, this can be fixed by installing the following package, like described in this StackOverflow answer:
apt-get install libpq-dev
  • pycrypto requires the python-dev tools to be installed. python3-dev should be installed for Python3

Creating the Python virtual environment

This guide explains how to prepare the Python development environment using the built-in venv module and pip. Assuming that the aiohttp-three-template repository was cloned in the local machine, and that Python >= 3.4.2 is installed in the host:

  • open a cmd / terminal in the root folder of the cloned repository
  • to create a virtual environment in a folder called env, run:
# Linux distribution with python3 PATH name assigned to Python 3
python3 -m venv env

# Windows
py -3 -m venv env
  • restore dependencies, using the provided requirements.txt:
# Linux:
env/bin/pip install -r requirements.txt      

# Windows:
env\Scripts\pip install -r requirements.txt

Setting up PostgreSQL

To use the master branch of the repository with all the provided features, an instance of PostgreSQL database server is required. Follow the instructions in the dedicated wiki page for further information.