#1 by Andrea
Hi everyone! I got this error in compiling a otree code, to generate the server. How can I solve it? Manyy thanks
otree devserver
Open your browser to http://localhost:8000/
To quit the server, press Control+C.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/otree", line 11, in <module>
load_entry_point('otree==5.10.4', 'console_scripts', 'otree')()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/main.py", line 112, in execute_from_command_line
call_command(cmd, *argv[2:])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/cli/base.py", line 32, in call_command
module.Command().outer_handle(args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/cli/base.py", line 10, in outer_handle
return self.handle(**vars(options))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/cli/devserver_inner.py", line 56, in handle
run_asgi_server(addr, port, is_devserver=True)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/cli/prodserver1of2.py", line 13, in run_asgi_server
run_uvicorn(addr, port, is_devserver=is_devserver)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/cli/prodserver1of2.py", line 33, in run_uvicorn
server.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/server.py", line 49, in run
loop.run_until_complete(self.serve(sockets=sockets))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/server.py", line 56, in serve
config.load()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/config.py", line 308, in load
self.loaded_app = import_from_string(self.app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/importer.py", line 20, in import_from_string
module = importlib.import_module(module_str)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/asgi.py", line 12, in <module>
from .urls import routes
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/urls.py", line 10, in <module>
from otree.channels.routing import websocket_routes
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/channels/routing.py", line 2, in <module>
from . import consumers as cs
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/channels/consumers.py", line 36, in <module>
from otree.room import ROOM_DICT, LabelRoom, NoLabelRoom
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/room.py", line 133, in <module>
ROOM_DICT = get_room_dict()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/room.py", line 128, in get_room_dict
room_object = NoLabelRoom(**room)
TypeError: __init__() got an unexpected keyword argument 'use_secure_urls'
#2 by ChristianK
Hi Andrea, which version of oTree are you running? Get it with the command: otree --version Can you also post your room config from settings.py, please? Best Christian
#3 by Andrea (edited )
Hi Christian,
the version is 5.10.4, but the code was written for the 2.5.5 version.
Here's the room config:
ROOMS = [
dict(
name='Prolific_1',
display_name='Prolific_1',
use_secure_urls=False
),
dict(
name='Prolific_2',
display_name='Prolific_2',
use_secure_urls=False
),
dict(
name='Prolific_3',
display_name='Prolific_3',
use_secure_urls=False
),
dict(
name='SONA_1',
display_name='SONA_1',
use_secure_urls=False
),
dict(
name='SONA_2',
display_name='SONA_2',
use_secure_urls=False
),
dict(
name='SONA_3',
display_name='SONA_3',
use_secure_urls=False
),
dict(
name='BELSS',
display_name='BELSS',
participant_label_file='_rooms/belss.txt',
use_secure_urls=True
),
dict(
name='30463',
display_name='Intro to Cognitive Science',
use_secure_urls=False
),
dict(
name='live_demo',
display_name='Room for Live Demo (No Participant Labels)',
)
]
Thank you!
#4
by
Furuneko
As you can see in the last lines of the logs, the argument 'use_secure_urls' is not expected when you use a Room without participant labels:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/otree/room.py", line 128, in get_room_dict
room_object = NoLabelRoom(**room)
TypeError: __init__() got an unexpected keyword argument 'use_secure_urls'
For a room as the following:
dict(
name='30463',
display_name='Intro to Cognitive Science',
use_secure_urls=False
)
that argument should be removed.
See also the official documentation on this:
https://otree.readthedocs.io/en/latest/rooms.html#use-secure-urls-optional
#5 by ChristianK
Remove the "use_secure_urls=False" statements from your room configs and it should work. There might be a slight inconsistency in the advice oTree gives: If you set use_secure_urls to True, but do not provide a participant_label_file, it tells you to: "ValueError: Room "econ": you must either set participant_label_file, or set use_secure_urls=False" If you then set use_secure_urls to False, you get the error you are seeing. So the advice is not quite right.
#6 by Andrea
Thank you, it worked!!