Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 调用heroku run时FileNotFoundError";otree resetdb";_Python_Git_Heroku_Otree - Fatal编程技术网

Python 调用heroku run时FileNotFoundError";otree resetdb";

Python 调用heroku run时FileNotFoundError";otree resetdb";,python,git,heroku,otree,Python,Git,Heroku,Otree,因此,我收到一个FileNotFoundError:[Errno 2]没有这样的文件或目录错误,我真的不知道该怎么办,因为文件肯定在那里。在heroku运行“oTree resetdb”命令之后,我尝试使用heroku和git部署oTree实验时发生错误。操作系统是Windows10 完整错误消息: Running otree resetdb on ⬢ otreeexperimentna... up, run.5607 (Free) Traceback (most recent call las

因此,我收到一个
FileNotFoundError:[Errno 2]没有这样的文件或目录错误
,我真的不知道该怎么办,因为文件肯定在那里。在heroku运行“oTree resetdb”命令之后,我尝试使用heroku和git部署oTree实验时发生错误。操作系统是Windows10

完整错误消息:

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'
它也不起作用,有类似的错误消息

有什么问题吗?文件products.json在那里,并且不是空的,所以我不知道为什么它不工作。我还试着在我的笔记本电脑上运行这个实验,它工作得非常好,所以我想问题在于heroku上的部署。欢迎任何建议,非常感谢

最好的,
丽娜

我想出来了。解决方案是将
.json
文件的路径重写为相对路径(而不是绝对路径)

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)