ModuleNotFoundError: No module named 'otree.db'

306 views Asked by At

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'm using Windows10, oTree version: 5.8.1. I tried to reinstall oTree but it didn't work. What can I do?

1

There are 1 answers

0
Poza On

The question was crossposted on https://groups.google.com/g/otree/c/pyQgYWeSW2Y/m/IV-a0iORAAAJ. The answer there was:

"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."

See this discussion on why you should not crosspost: https://meta.stackexchange.com/questions/141823/is-cross-posting-wrong-to-an-external-site