February 2022

If you originally developed your experiment in an old version of oTree such as 2.x or 3.x, then it may not run in the latest version. One option is to manually upgrade your code to the latest version of oTree, but this may not be an option for you because:

  1. If the project was written years ago or used undocumented features such as Django integration, it may take a lot of work to upgrade it to the latest version.
  2. Even if you can upgrade it to the latest oTree version, certain things might be slightly different. To guarantee reproducibility, it's safest to run it in the same version of oTree.

Using an old version of oTree is easy. First, run this command (change 2.3.4 to whatever version you want to use):

pip3 install otree==2.3.4

Also, open your project's requirements.txt or requirements_base.txt. In one of those files, there will be a line with the oTree version. Change that to: otree==2.3.4 (substitute the version you want). This tells Heroku to also use that version. If you skip this step, you might end up with a different version of oTree on Heroku vs. locally, producing inconsistent results.

What if I need 2 different versions of oTree?

You might want 2 different versions of oTree, for example, if you are running an old experiment, but also developing a new experiment in the latest version. This is no problem. You can install many versions of oTree using separate Python virtual environments, a.k.a. "virtualenv". You can find lots of info online, but I will summarize here.

First, it's best to install the same version of Python you originally ran the experiment with. For example, if you ran it with Python 3.6, then install a Python 3.6.x release from python.org. (This is necessary because some old versions of oTree don't run on the latest Python version.) You can have multiple versions of Python, such as 3.9 and 3.6, installed at the same time.

If you aren't sure what version of Python the old experiment was developed on, you can consult this table and look at what version of Python was released when you ran your experiment. But oTree tends to run a bit behind the latest release, so try using 1 minor version older, e.g. 3.5 instead of 3.6. (Anyway, if you try installing oTree on the wrong version of Python, usually it will tell you "wrong python version" immediately.)

On Windows, go to your project folder and run a command similar to this:

py -3.6 -m venv venv

(This command says to create a Python 3.6 virtual environment, and to store that virtualenv's executable files in a folder called venv/.)

Then activate this virtualenv with:


(This command runs an executable called activate which is located inside the folder venv/Scripts/.)

Install your desired version of oTree:

pip3 install otree==2.3.4

Then you can run otree devserver and all other commands. Each time you open your terminal/PowerShell, you need to re-activate that virtualenv with the above 'activate' command.

Now that you are using virtualenv for one project, you should start using it for all projects. Repeat the above steps for as many different oTree versions as you need.