oTree Forum >

Deployment Failure through oTree Hub

#1 by ynyyny

Hi Chris,

I am using oTree Hub to deploy one oTree program to Heroku and the following is the error I received:

"""
Build output
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> Using Python version specified in runtime.txt
 !     
 !     Python 3.7 reached its upstream end-of-life on June 27th, 2023, so no longer
 !     receives any security updates:
 !     https://devguide.python.org/versions/#supported-versions
 !     
 !     Support for Python 3.7 will be removed from this buildpack in October 2023.
 !     
 !     Upgrade to a newer Python version as soon as possible to keep your app secure.
 !     See: https://devcenter.heroku.com/articles/python-runtimes
 !     
 !     
 !     A Python security update is available! Upgrade as soon as possible to: python-3.7.17
 !     See: https://devcenter.heroku.com/articles/python-runtimes
 !     
-----> Installing python-3.7.15
-----> Installing pip 23.2.1, setuptools 68.0.0 and wheel 0.41.0
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting otree<5,>=3.4.0 (from -r requirements.txt (line 4))
         Downloading otree-3.4.0.tar.gz (321 kB)
         Preparing metadata (setup.py): started
         Preparing metadata (setup.py): finished with status 'done'
       Collecting psycopg2<2.9,>=2.8 (from -r requirements.txt (line 5))
         Downloading psycopg2-2.8.6.tar.gz (383 kB)
         Preparing metadata (setup.py): started
         Preparing metadata (setup.py): finished with status 'done'
       Collecting sentry-sdk==0.7.9 (from -r requirements.txt (line 6))
         Downloading sentry_sdk-0.7.9-py2.py3-none-any.whl (61 kB)
       Collecting urllib3 (from sentry-sdk==0.7.9->-r requirements.txt (line 6))
         Obtaining dependency information for urllib3 from https://files.pythonhosted.org/packages/37/dc/399e63f5d1d96bb643404ee830657f4dfcf8503f5ba8fa3c6d465d0c57fe/urllib3-2.0.5-py3-none-any.whl.metadata
         Downloading urllib3-2.0.5-py3-none-any.whl.metadata (6.6 kB)
       Collecting certifi (from sentry-sdk==0.7.9->-r requirements.txt (line 6))
         Obtaining dependency information for certifi from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
         Downloading certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
       Collecting asgiref==3.2.7 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
       Collecting colorama==0.4.1 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading colorama-0.4.1-py2.py3-none-any.whl (15 kB)
       Collecting dj-database-url==0.5.0 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
       Collecting Django==2.2.12 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading Django-2.2.12-py3-none-any.whl (7.5 MB)
       Collecting django-vanilla-views==1.0.6 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading django_vanilla_views-1.0.6-py2.py3-none-any.whl (8.9 kB)
       Collecting h11 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading h11-0.14.0-py3-none-any.whl (58 kB)
       Collecting h2>=3.1.0 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading h2-4.1.0-py3-none-any.whl (57 kB)
       Collecting priority (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading priority-2.0.0-py3-none-any.whl (8.9 kB)
       Collecting pytz==2019.2 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading pytz-2019.2-py2.py3-none-any.whl (508 kB)
       Collecting termcolor==1.1.0 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading termcolor-1.1.0.tar.gz (3.9 kB)
         Preparing metadata (setup.py): started
         Preparing metadata (setup.py): finished with status 'done'
       Collecting toml (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
       Collecting typing_extensions (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Obtaining dependency information for typing_extensions from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata
         Downloading typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
       Collecting whitenoise==4.1.3 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading whitenoise-4.1.3-py2.py3-none-any.whl (20 kB)
       Collecting wsproto>=0.14.0 (from otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading wsproto-1.2.0-py3-none-any.whl (24 kB)
       Collecting sqlparse (from Django==2.2.12->otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading sqlparse-0.4.4-py3-none-any.whl (41 kB)
       Collecting hyperframe<7,>=6.0 (from h2>=3.1.0->otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading hyperframe-6.0.1-py3-none-any.whl (12 kB)
       Collecting hpack<5,>=4.0 (from h2>=3.1.0->otree<5,>=3.4.0->-r requirements.txt (line 4))
         Downloading hpack-4.0.0-py3-none-any.whl (32 kB)
       Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
       Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
       Downloading urllib3-2.0.5-py3-none-any.whl (123 kB)
       Building wheels for collected packages: otree, termcolor, psycopg2
         Building wheel for otree (setup.py): started
         Building wheel for otree (setup.py): finished with status 'done'
         Created wheel for otree: filename=otree-3.4.0-py3-none-any.whl size=450935 sha256=f5cc8a60035da793fedf0bef0842a72a89055ed730f6803b41571c2e3366e9b0
         Stored in directory: /tmp/pip-ephem-wheel-cache-uccg5hmj/wheels/b4/54/5a/5e3493be6db4476e6ccb9e843187c106ad29ada3d60d1dde09
         Building wheel for termcolor (setup.py): started
         Building wheel for termcolor (setup.py): finished with status 'done'
         Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4831 sha256=91ecbccbe9a10058f77c832d6725c25f4f276bf1ef0b592daf8bcf19147dae43
         Stored in directory: /tmp/pip-ephem-wheel-cache-uccg5hmj/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
         Building wheel for psycopg2 (setup.py): started
         Building wheel for psycopg2 (setup.py): finished with status 'done'
         Created wheel for psycopg2: filename=psycopg2-2.8.6-cp37-cp37m-linux_x86_64.whl size=143959 sha256=f5a0ac537eeef97c08a2776f33c4e0e4aa32703d2e6f484bac038701406bd789
         Stored in directory: /tmp/pip-ephem-wheel-cache-uccg5hmj/wheels/25/78/75/9c0323f7e1fb42143cbd2439302beb7850a1034abb961cb281
       Successfully built otree termcolor psycopg2
       Installing collected packages: whitenoise, termcolor, pytz, django-vanilla-views, dj-database-url, urllib3, typing_extensions, toml, sqlparse, psycopg2, priority, hyperframe, hpack, colorama, certifi, asgiref, sentry-sdk, h2, h11, Django, wsproto, otree
       Successfully installed Django-2.2.12 asgiref-3.2.7 certifi-2023.7.22 colorama-0.4.1 dj-database-url-0.5.0 django-vanilla-views-1.0.6 h11-0.14.0 h2-4.1.0 hpack-4.0.0 hyperframe-6.0.1 otree-3.4.0 priority-2.0.0 psycopg2-2.8.6 pytz-2019.2 sentry-sdk-0.7.9 sqlparse-0.4.4 termcolor-1.1.0 toml-0.10.2 typing_extensions-4.7.1 urllib3-2.0.5 whitenoise-4.1.3 wsproto-1.2.0
-----> $ python manage.py collectstatic --noinput
       Traceback (most recent call last):
         File "manage.py", line 11, in <module>
           execute_from_command_line(sys.argv, script_file=__file__)
         File "/app/.heroku/python/lib/python3.7/site-packages/otree_startup/__init__.py", line 160, in execute_from_command_line
           configure_settings(DJANGO_SETTINGS_MODULE)
         File "/app/.heroku/python/lib/python3.7/site-packages/otree_startup/__init__.py", line 185, in configure_settings
           user_settings_module = import_module(DJANGO_SETTINGS_MODULE)
         File "/app/.heroku/python/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 "/tmp/build_b045a4cb/settings.py", line 9, in <module>
           import redis
       ModuleNotFoundError: No module named 'redis'

 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.

       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:

          $ heroku config:set DISABLE_COLLECTSTATIC=1

       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.

 !     Push failed
 """
 
 
 Could you help me diagnose the problem? This program runs perfectly in my local laptop. Not sure what I should do to get it run online.
 
 Many thanks!!

#2 by Chris_oTree

looks like your settings.py contains the line 'import redis' for some reason...if so, delete it.

#3 by ynyyny

Thank you very much Chris!

I have followed your instructions and removed the commands containing "redis" and now it works.

However, when testing the code on Heroku, I met with an error that never occurred when I tested the code locally. Please see below part of the log. I am not sure how to diagnose the problem. I would really appreciate it if you could help me with this issue!


"""
2023-09-25T02:26:18.286275+00:00 app[web.1]: 10.1.22.141:13679 http "GET /p/xy4yz2g7/online_study/Instruction_client/7/ 1.1" 200
2023-09-25T02:26:18.286304+00:00 heroku[router]: at=info method=GET path="/p/xy4yz2g7/online_study/Instruction_client/7/" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=32802e80-1de9-48e5-b36d-5520cebbecc9 fwd="50.231.141.121" dyno=web.1 connect=0ms service=82ms status=200 bytes=7311 protocol=https
2023-09-25T02:26:18.397322+00:00 heroku[router]: at=info method=GET path="/auto_advance/?participant_code=xy4yz2g7&page_index=6" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=0db4c2f4-6587-40cd-8888-f36fe973d1f2 fwd="50.231.141.121" dyno=web.1 connect=0ms service=4838ms status=101 bytes=170 protocol=https
2023-09-25T02:26:18.634620+00:00 app[web.1]: 10.1.51.238:31213 ws "GET /auto_advance/ 1.1" 101
2023-09-25T02:26:22.242727+00:00 app[web.1]: INFO own_time=52ms request_id=41c1565d-8502-4a49-9709-3158e76b20b7
2023-09-25T02:26:22.244997+00:00 app[web.1]: 10.1.22.141:13347 http "POST /p/xy4yz2g7/online_study/Instruction_client/7/ 1.1" 200
2023-09-25T02:26:22.245195+00:00 heroku[router]: at=info method=POST path="/p/xy4yz2g7/online_study/Instruction_client/7/" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=41c1565d-8502-4a49-9709-3158e76b20b7 fwd="50.231.141.121" dyno=web.1 connect=0ms service=57ms status=200 bytes=7614 protocol=https
2023-09-25T02:26:22.292488+00:00 heroku[router]: at=info method=GET path="/auto_advance/?participant_code=xy4yz2g7&page_index=7" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=e32fa2f0-f826-488c-928b-decc1146e7e0 fwd="50.231.141.121" dyno=web.1 connect=0ms service=3681ms status=101 bytes=170 protocol=https
2023-09-25T02:26:22.486141+00:00 app[web.1]: 10.1.18.155:29439 ws "GET /auto_advance/ 1.1" 101
2023-09-25T02:26:28.542378+00:00 app[web.1]: INFO own_time=41ms request_id=177e971d-7bba-44c4-bf10-28b0e0db1625
2023-09-25T02:26:28.544578+00:00 heroku[router]: at=info method=POST path="/p/xy4yz2g7/online_study/Instruction_client/7/" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=177e971d-7bba-44c4-bf10-28b0e0db1625 fwd="50.231.141.121" dyno=web.1 connect=0ms service=46ms status=302 bytes=317 protocol=https
2023-09-25T02:26:28.544799+00:00 app[web.1]: 10.1.22.141:17339 http "POST /p/xy4yz2g7/online_study/Instruction_client/7/ 1.1" 302
2023-09-25T02:26:28.631378+00:00 app[web.1]: ERROR Internal Server Error: /p/xy4yz2g7/online_study/Instruction_summary/8/
2023-09-25T02:26:28.631381+00:00 app[web.1]: Traceback (most recent call last):
2023-09-25T02:26:28.631384+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree/views/abstract.py", line 199, in dispatch
2023-09-25T02:26:28.631385+00:00 app[web.1]: response.render()
2023-09-25T02:26:28.631385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/template/response.py", line 106, in render
2023-09-25T02:26:28.631386+00:00 app[web.1]: self.content = self.rendered_content
2023-09-25T02:26:28.631397+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/template/response.py", line 81, in rendered_content
2023-09-25T02:26:28.631398+00:00 app[web.1]: template = self.resolve_template(self.template_name)
2023-09-25T02:26:28.631398+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/template/response.py", line 63, in resolve_template
2023-09-25T02:26:28.631399+00:00 app[web.1]: return select_template(template, using=self.using)
2023-09-25T02:26:28.631399+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader.py", line 47, in select_template
2023-09-25T02:26:28.631399+00:00 app[web.1]: raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
2023-09-25T02:26:28.631400+00:00 app[web.1]: django.template.exceptions.TemplateDoesNotExist: online_study/Instruction_summary.html
2023-09-25T02:26:28.635030+00:00 app[web.1]: INFO own_time=42ms request_id=1157a435-01c3-45f0-b803-61fd7b51f98d
2023-09-25T02:26:28.637334+00:00 app[web.1]: 10.1.22.141:30523 http "GET /p/xy4yz2g7/online_study/Instruction_summary/8/ 1.1" 500
2023-09-25T02:26:28.637624+00:00 heroku[router]: at=info method=GET path="/p/xy4yz2g7/online_study/Instruction_summary/8/" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=1157a435-01c3-45f0-b803-61fd7b51f98d fwd="50.231.141.121" dyno=web.1 connect=0ms service=46ms status=500 bytes=741 protocol=https
2023-09-25T02:26:28.840587+00:00 heroku[router]: at=info method=GET path="/auto_advance/?participant_code=xy4yz2g7&page_index=7" host=yangnanyin-online-66cf327e9f54.herokuapp.com request_id=200b6328-fd5a-40c3-b3be-48e1aab8bc02 fwd="50.231.141.121" dyno=web.1 connect=0ms service=6384ms status=101 bytes=170 protocol=https
"""

#4 by Chris_oTree

TemplateDoesNotExist: online_study/Instruction_summary.html

Write a reply

Set forum username