python - dokku 上的预部署命令失败
问题描述
我的 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 没有被激活。这很奇怪,因为诗歌应该处理这个问题。
然而,一方面,heroku 不支持诗歌。
您可以使用此构建包: https ://elements.heroku.com/buildpacks/moneymeets/python-poetry-buildpack
根据文档,collectstatic 应该在部署期间自动发生: https ://devcenter.heroku.com/articles/django-assets#collectstatic-during-builds
最后:poetry buildpack 只创建一个 requirements.txt,然后由 requular heroku python buildpack 与 pip 一起安装。
推荐阅读
- postgresql - Intellij SSH 到远程数据库
- c - 全局函数未返回正确的值
- c++ - 为什么我不能在这个向量上使用 push_back?
- selenium - 搜索字段在远程(专家)chorme v91 中不起作用
- python - 为什么在熊猫中创建数据透视表时十进制不起作用?
- python - 对多个数组中的值求和的更有效方法
- javascript - 我在哪里可以找到 JavaScript 中 test() 方法的文档?
- recommender-systems - 为我的网站使用 DLRM/facebook 的推荐系统
- c# - 异步任务的 SemaphoreSlim 问题
- react-native - react-native-maps - 移动地图时标记不会消失