Python dokku上的Predeploy命令失败

Python dokku上的Predeploy命令失败,python,dokku,python-poetry,Python,Dokku,Python Poetry,我的app.json看起来像这样 { "scripts": { "dokku": { "predeploy": "poetry run python manage.py collectstatic --noinput && poetry run python manage.py migrate" } } } 它给出了这个错误 ! Predeploy command declared: 'poetry run py

我的app.json看起来像这样

{
    "scripts": {
      "dokku": {
        "predeploy": "poetry run python manage.py collectstatic --noinput && poetry run python manage.py migrate"
      }
    }
}
它给出了这个错误

 !     Predeploy command declared: 'poetry run python manage.py collectstatic --noinput && poetry run python manage.py migrate'
remote: execution of 'poetry run python manage.py collectstatic --noinput && poetry run python manage.py migrate' failed!
       Creating virtualenv foxflash-9TtSrW0h-py3.6 in /app/.cache/pypoetry/virtualenvs
       Traceback (most recent call last):
         File "manage.py", line 9, in main
           from django.core.management import execute_from_command_line
       ModuleNotFoundError: No module named 'django'
       The above exception was the direct cause of the following exception:
       Traceback (most recent call last):
         File "manage.py", line 20, in <module>
           main()
         File "manage.py", line 15, in main
           ) from exc
       ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

老实说,我不知道该多尝试些什么

您看到的是virtualenv没有被激活。这很奇怪,因为诗歌应该处理这个问题

然而,赫罗库不支持诗歌

您可以使用此构建包:

根据文档,在部署过程中应自动进行收集:


最后:Poethy构建包只创建一个requirements.txt,然后由reqular heroku python构建包与pip一起安装

当你称诗歌为“奔跑”时,诗歌会在找不到虚拟环境的情况下创建一个新的虚拟环境。这个新的虚拟环境不会像django那样安装任何依赖项。我不知道dokku是什么,但如果您将系统python设置为直接运行django应用程序,您可以通过创建一个名为POETRY_VIRTUALENVS_CREATE的环境变量来解决问题,并将其设置为false。谢谢@rolaand van laar,我不是在使用heroku,而是使用dokku。不使用任何构建包,一切都是通过dockerfile完成的我会看看构建包是否提供了任何线索。dokku的行为就像heroku。工作出色!