Installing oTree on Windows

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)

If the below steps don’t work for you, please email chris@otree.org with details.

Step 1: Install Python

Download and install Python 3.6. Check the box to add Python to PATH:

_images/py-win-installer.png

Step 2: Install oTree

Go to the folder where you want to create your oTree project. Then click the “File” menu and open PowerShell:

_images/open-powershell.png

Enter this command at the prompt:

pip3 install -U otree

Note

If you get an error like this:

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

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

Step 3: Run oTree

Create your project folder:

otree startproject oTree

When it asks you “Include sample games?” choose yes.

Move into the folder you just created:

cd oTree

Run the server:

otree devserver

Open your browser to http://localhost:8000/. You should see the oTree demo site.

To stop the server, press Control + C at your command line.

Step 4: Install PyCharm

Install PyCharm, which you will use for editing your Python files.

After installing, open PyCharm, go to “File -> Open...” and select your project folder (It’s usually C:\Users\<your_username>\oTree).

Then click File –> Settings and click through the following steps:

  • “Project -> Project interpreter”
  • Click the “gear” icon
  • Add...
  • System Interpreter

And set it to the location of your Python executable, which you can get in your command prompt by entering powershell -command "get-command python". Usually it is C:\Program Files\Python36-64\python.exe or C:\Users\<your_username>\AppData\Local\Programs\Python\Python36-64\python.exe. Once it’s configured, the imports at the top of an app’s models.py should look like this , not this.

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

_images/pycharm-psycopg2-warning.png

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

_images/pycharm-autocomplete.gif

Upgrading/reinstalling oTree

We recommend you upgrade 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.

The command to upgrade is the same as the command to install:

pip3 install -U otree

If there is a problem with the upgrade, uninstall then reinstall:

pip3 uninstall otree pip3 install -U otree