Hello guys,
so I receive a FileNotFoundError: [Errno 2] No such file or directory error
. The error occurs when I try to deploy an oTree experiment with heroku and git after command heroku run "otree resetdb"
. Operating system is Windows 10. I honestly don't know what to do since the file is certainly there
Full error message:
Running otree resetdb on ⬢ otreeexperimentna... up, run.5607 (Free)
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/otree_startup/__init__.py", line 227, in do_django_setup django.setup()
File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models()
File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name)
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 "/app/experimentMusic/models.py", line 21, in <module> class Constants(BaseConstants):
File "/app/experimentMusic/models.py", line 26, in Constants
with open('D:\Experiment\oTreeproject\oTreeonlineshop-master\shop\oTree\experimentMusic\products.json', 'r', encoding='utf-8') as jsonfile: FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Experiment\\oTreeproject\\oTreeonlineshop-master\\shop\\oTree\\experimentMusic\\products.json'
I also tried a version of code with normal slashes and with double backslashes and still received the same error. Next I tried to rewrite the path in models.py
using Path from pathlib as follows:
from pathlib import Path
with open(Path('D:/Experiment/oTreeproject/oTreeonlineshop-master/shop/oTree/experimentMusic/products.json'), 'r', encoding='utf-8') as jsonfile:
data=jsonfile.read()
shoppinglist = json.loads(data)
It also didn't work, with similar error message.
What could be the problem? The file products.json
is there and is not empty, so I have no clue why it doesn't work. I also tried to run the experiment on my local server and it works perfectly fine, so I guess the problem is the deployment on heroku. Any advice is welcome, thanks so much!
Best, Lina