将存储库推送到 heroku master 后出现此错误([Errno 2] 没有这样的文件或目录)。这是我的日志。
2012-04-17T18:24:53+00:00 app[web.1]: python: can't open file '/test/project/manage.py': [Errno 2] No such file or directory
2012-04-17T18:24:54+00:00 heroku[web.1]: Process exited with status 2
2012-04-17T18:24:54+00:00 heroku[web.1]: State changed from starting to crashed
2012-04-17T18:24:54+00:00 heroku[web.1]: State changed from crashed to created
2012-04-17T18:24:54+00:00 heroku[web.1]: State changed from created to starting
2012-04-17T18:24:57+00:00 heroku[web.1]: Starting process with command python /test/project/manage.py runserver 0.0.0.0:4473 --noreload 2012-04-17T18:24:57+00:00 app[web.1]: python: can't open file '/test/project/manage.py': [Errno 2] No such file or directory
我的 Procfile 如下所示:
web: python /test/project/manage.py runserver 0.0.0.0:$PORT --noreload
不知道为什么打不开文件。当我使用我的开发服务器时,它打开得很好。有任何想法吗?谢谢阅读。
最佳答案
您当前在 Procfile 中的设置引用了 Heroku 上不存在的绝对路径“/test/project/manage.py”。 '/test/是您正在运行的实例的根,并且不正确。您应该首先将其更改为相对路径,这可能类似于:
web: python project/manage.py runserver 0.0.0.0:$PORT --noreload
如果这不起作用,您可以通过运行以下命令探索项目的位置:
heroku run bash
这应该将您置于“/app”中,您可以从这里看到启动项目的路径。
由于您的初始推送可能无法启动流程,因此您可能需要扩展网络流程。然后你可以这样做:
heroku scale web=1
关于python - 使用 Heroku 的 Django 部署 - [Errno 2] 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10200732/