#1 by interdisciplinary
Hi oTree Developers and Community, I'm a beginner oTree user and have encountered a persistent and very unusual set of issues trying to set up a new oTree project on my Mac, and I'm hoping for some guidance. My Environment: OS: macOS m3mac sonoma 14.4 Python: 3.12.3 (installed from python.org, using venv for projects) oTree Versions Tried: Primarily 5.11.2, also attempted 5.10.4. (Installed via pip install otree or pip install otree==<version> into a fresh venv). Problem 1: otree startapp <appname> Creates Incorrect App Structure No matter what I try (new project folders in different locations, new virtual environments, pip install --force-reinstall --no-cache-dir otree, different oTree 5.x versions, different app names), otree startapp <appname> consistently creates an app folder with the following incorrect structure directly inside the app folder: MyPage.html Results.html __init__.py __pycache__/ It's missing the standard tests.py file and, crucially, the templates/<appname>/ subdirectory (where MyPage.html and Results.html should be). I understand that for oTree 5+, models.py and pages.py are consolidated into __init__.py (the "noself" format), but the overall structure created by startapp still seems incorrect. Diagnostic Finding: When I inspect the oTree installation's own blueprint folder at venv/lib/python3.12/site-packages/otree/app_template/, its contents are listed as: __init__.py, __pycache__, _builtin, models.py, pages.py, templates, tests.py It appears that models.py, pages.py etc., are directly in app_template, rather than within a nested subdirectory that startapp would normally copy and rename. This seems to be the root cause of startapp producing a malformed app. This flat structure in site-packages/otree/app_template/ appears consistently even after fresh, forced reinstalls of oTree. Problem 2: Docker Image Pull Failure (Separate Troubleshooting Attempt) In an attempt to bypass local installation issues, I tried using Docker: docker pull hello-world works perfectly. I have successfully run docker login. However, docker pull otree/otree (and otree/otree-lite, and specific tags like otree/otree:5.11.2) consistently fails with: Error response from daemon: pull access denied for otree/otree, repository does not exist or may require 'docker login' I also have difficulty accessing the https://hub.docker.com/r/otree/otree/tags page directly in my browser (it often fails to load or shows errors). This suggests a specific issue accessing this oTree Docker Hub repository from my machine/network. Summary of Troubleshooting Done: Multiple completely new project directories and virtual environments (venv). pip install --upgrade pip within venvs. pip install otree (latest 5.x). pip install --force-reinstall --no-cache-dir otree. pip install otree==5.11.2 and pip install otree==5.10.4. Verified which otree points to the venv's executable. Verified oTree version with otree --version. Ensured commands are run in the correct directories. Checked settings.py for completeness (including CSRF middleware/processors after initial KeyError: 'csrftoken' on a manually created page). I'm at a loss as to why the oTree installation results in a malformed app_template structure and why I'm having such specific trouble with the official Docker images. Any insights or suggestions on how to get a correctly functioning oTree setup would be immensely appreciated. I had a project working previously, but encountered a CSRF token issue, and since attempting to resolve that and starting fresh, I've been stuck with these fundamental setup problems. Thank you for your time and help
#2
by
BonnEconLab
Have you tried running `otree devserver` after generating your app? Or have you tried running `otree startproject example_games`, replied `y` to the question `Include sample games? (y or n)`, and then run `otree devserver`? oTree should run perfectly fine. You will see that, e.g., example_games/survey also only contains __init__.py CognitiveReflectionTest.html Demographics.html That is, the “flat” contents of the app folder MyPage.html Results.html __init__.py __pycache__/ are not a bug, they are a feature. They are perfectly fine for oTree to function properly. You *can* still generate a templates/<appname>/ subdirectory, as you may be used to from using Django, but there is no need to do so!