oTree Forum >

problem with "from otree.models import Group"

#1 by yadf94

Hello,

In my code, i started by "

from otree.currency import Currency as c, currency_range
from random import randrange
from otree.models import Group
from otree.api import *

"

Nothing fancy right ... But when i "otree zip" and then "otree resetbet" (or "otree runserver"), through pycharm, i got the error message : " File "C:\Users\ASUS ZENBOOK\PycharmProjects\pythonProject2\efrei\test1\__init__.py", line 3, in <module>
    from otree.models import Group
ImportError: cannot import name 'Group' from 'otree.models' (C:\Users\ASUS ZENBOOK\PycharmProjects\pythonProject2\venv\lib\site-packages\otree\models\__init__.py)
"

I'm stuck on this... And i also tried on otreehub deployment (upload then resetdb), same error...

Thanks in advance for your help !

Yann

#2 by Chris_oTree

You should only import from otree.api. The imports from otree.currency etc are unnecessary.

#3 by yadf94

Hello Chris_oTree, thanks for you reply! I shifted to :

"from random import randrange
from otree.api import Group
from otree.api import *"

and i got the error message : "ImportError: cannot import name 'Group' from 'otree.api' " after otree zip and otree resetdb.

Cheers

#4 by yadf94

Hello problem solved : it was about using BaseGroup instead of Group (with import and in the code)...

Write a reply

Set forum username