ModuleNotFoundError: No module named 'otree.db'

131 views
Skip to first unread message

deniz turkbayragi

unread,
May 4, 2022, 5:34:13 PM5/4/22
to oTree help & discussion
Hello, I've been searching about this error but I couldn't find a useful solution. I'm trying to run my old projects,  I'm using Windows10, oTree version: 5.8.1. When I try to run oTree with `otree devserver' command in my project folder's shell, I get the following error:
Traceback (most recent call last): File "C:\Users\Username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\otree\database.py", line 268, in init_orm models = get_models_module(app) File "C:\Users\Username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\otree\common.py", line 75, in get_models_module return import_module(module_name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "C:\Users\Username\Desktop\oTree\chp1a\models.py", line 6, in <module> from otree.db import models ModuleNotFoundError: No module named 'otree.db'

I tried to reinstall oTree but it didn't work. What can I do?

Chris @ oTree

unread,
May 4, 2022, 5:52:02 PM5/4/22
to deniz turkbayragi, oTree help & discussion
Apparently in the file chp1a\models.py", line 6, you have this line:

from otree.db import models

That should not be there. your code should only import from otree.api. 

Sent from my phone
Reply all
Reply to author
Forward
0 new messages