Installing oTree

Important note

If you publish research conducted using oTree, you are required by the oTree license to cite this paper. (Citation: Chen, D.L., Schonger, M., Wickens, C., 2016. oTree - An open-source platform for laboratory, online and field experiments. Journal of Behavioral and Experimental Finance, vol 9: 88-97)

Step 0: Install postgresql and redis (for Debian/Ubuntu users)

ibsen-oTree requires postgresql and redis in order to work

sudo apt-get install redis-server

For redis we need to edit the redis conf file and set the default password specified in

sudo vi /etc/redis/redis.conf

Add this line to the end of the file

requirepass 0WfZXD1QfJ9Rnsancr0JrRHI8ov1JQ1YxAvy6g9bE8GMHS0bTmiBbs0G2LmurT9gkdSNu8ZmMikFi9TecGrE0OCgbzZQb0CrURsJWa6M8bnEEDeQywhItJrHJAW1T39Q

Postgresql installation

sudo apt-get install postgresql
sudo apt-get install libpq-dev

For postgres, we need to create our default database and user and grant the required privileges

sudo -u postgres psql postgres

Inside postgres:

create database otree;
create role otree with password 'otree' login
grant all privileges on database otree to otree;

Step 1: Install required libraries (for Debian/Ubuntu users)

sudo apt-get install build-essential
sudo apt-get install virtualenv
sudo apt-get install libxml2-dev

Step 2: Install Python

oTree requires Python 3.5 or higher.

If you already have Python 3.x installed (check by entering pip3 -V at your command prompt), you can skip the below section. Or, uninstall your existing version of Python, and proceed with the below steps.

Step 2: Install Python 3.5 (for Windows users)

Download and install Python 3.5. (Python 3.4 and 3.5 are also OK.) Check the box to add Python to PATH:


Once setup is done, search in your Windows Start Menu for the program “PowerShell”, open PowerShell, and enter pip3 -V:


It will output a line that gives the version of Python at the end; this should match the version of Python you just installed:

Step 2: Install Python 3.5 (for macOS users)

You need to install Python 3.4 or higher. We recommend installing it with Homebrew. (However, if you already have Python 3.5 installed through Conda, that should be OK.)

  • In Finder, search for and open the “Terminal” app:
  • In the terminal window, type this and hit enter:
xcode-select --install

When prompted, select to install the “command line developer tools”.

ruby -e "$(curl -fsSL"
  • Update your PATH variable to state that homebrew packages should be used before system packages:

    echo "export PATH=/usr/local/bin:/usr/local/sbin:\$PATH" >> ~/.bash_profile
  • Reload .bash_profile to ensure the changes have taken place:

    source ~/.bash_profile
  • Install python:

    brew install python3
  • Then test that it worked:

    pip3 -V

It will output a line that gives the version of Python at the end; this should match the version of Python you just installed.

Step 2: Install Python 3.5 (for Linux/Unix users)

We recommmend installing using your system’s package manager to install Python 3.5. If Twisted fails to compile, install the python-dev package (e.g. through apt-get).

More information in the Linux server setup section.

Step 3: Install oTree

Enter this in PowerShell (Windows) or Terminal (macOS/Debian/Ubuntu) inside ibsen folder:

mkdir venv
virtualenv -p python3.5 venv
source venv/bin/activate
cd oTree
pip3.5 install -r requirements.txt
pip3.5 install -U ../otree-core


If you get this Windows error about Twisted and vcvarsall.bat:

error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from

To fix this, install the Visual C++ Build Tools.

Step 4: Run oTree

Open PowerShell (on Windows) or Terminal (on macOS), and run inside ibsen folder:

First activate your virtualenv:

source venv/bin/activate

And then:

otree startproject oTree

If it’s your first time, we recommend choosing the option to include the sample games.

The above command will create a folder named oTree in your home directory. (If you want, you can move the folder to another location.)

Then change to the directory you just created:

cd oTree


If you’ve never used a command prompt like Terminal or PowerShell, basically all you need to know is it is an alternative to your file explorer (or Finder on Mac). Instead of clicking on files and folders, you type commands to navigate folders and execute programs.

Here are some useful commands:

  • pwd: shows what folder you are currently in
  • ls: lists the files and subfolders in the current folder
  • cd: move to a subfolder. For example, cd oTree takes you to the subfolder oTree.

Reset the database:

otree resetdb

(You might see a message about migrations; you can ignore that.)

Then run the server:

otree runserver


If Python crashes when you run this command, and you’re using PowerShell, try using CMD instead.

Then open your browser to You should see the oTree demo site.

To stop the server, enter Control + C at your command line. To restart the server from the command line, pressing your keyboard’s “up” arrow (this will retrieve the last command you entered), and hit Enter.

Step 5: Install a Python editor (PyCharm)

You will need a text editor to write your Python code.

We recommend using PyCharm. Professional Editon is better than Community Edition because it makes Django programming easier. PyCharm Professional is free if you are a student, teacher, or professor.

Even if you normally use another text editor, we recommend at least trying PyCharm, because PyCharm’s autocompletion makes learning oTree much easier:


Once you have installed PyCharm, go to “File -> Open...” and select the folder you created with otree startproject.

Then click on File –> Settings (or Default Settings) and navigate to Languages & Frameworks -> Django, check “Enable Django Support” and set your oTree folder as the Django project root, with your and


If PyCharm displays this warning, select “Ignore requirements”:


Command line tips & tricks

Here are some tips to using PowerShell (for Windows users) or Terminal (for macOS users):

A few tips:

  • You can retrieve the previous command you entered by pressing your keyboard’s “up” arrow
  • If you get stuck running a command, you can press Control + C.
  • In PowerShell, you should right-click to paste a command.

Upgrading/reinstalling oTree

The oTree software has two components:

  • oTree-core: The engine that makes your apps run
  • oTree library: the folder of sample games and other files (e.g. that you download from here and customize to build your own project.

Upgrade oTree core

We recommend you do this on a weekly basis, so that you can get the latest bug fixes and features. This will also ensure that you are using a version that is consistent with the current documentation.


pip3 install -U ../otree-core
otree resetdb

Upgrade oTree library

Run otree startproject [folder name]. This will create a folder with the specified name and download the latest version of the library there.

If you originally installed oTree over 5 months ago, we recommend you run the above command and move your existing apps into the new project folder, to ensure you have the latest, etc.