我正试图通过AWS elastic beanstalk部署我的django应用程序;在过去的两天里,我遇到了一个问题,我已经缩小了范围
部署过程中的某个命令失败,此命令如下所示:
container_commands:
01_migrate:
command: "python3 manage.py migrate"
leader_only: true
AWS EB控制台日志中告诉我这一点的部分将我引向cfn-init.log,检查这一点告诉我同样的事情。然而,在cfn-init-cmd.log中,我看到了这一点
2020-06-19 18:24:24,753 P5019 [INFO] Command 01_migrate
2020-06-19 18:24:24,771 P5019 [INFO] -----------------------Command Output-----------------------
2020-06-19 18:24:24,771 P5019 [INFO] Traceback (most recent call last):
2020-06-19 18:24:24,771 P5019 [INFO] File "manage.py", line 10, in main
2020-06-19 18:24:24,771 P5019 [INFO] from django.core.management import execute_from_command_line
2020-06-19 18:24:24,771 P5019 [INFO] ModuleNotFoundError: No module named 'django'
2020-06-19 18:24:24,771 P5019 [INFO]
2020-06-19 18:24:24,771 P5019 [INFO] The above exception was the direct cause of the following exception:
2020-06-19 18:24:24,771 P5019 [INFO]
2020-06-19 18:24:24,772 P5019 [INFO] Traceback (most recent call last):
2020-06-19 18:24:24,772 P5019 [INFO] File "manage.py", line 21, in <module>
2020-06-19 18:24:24,772 P5019 [INFO] main()
2020-06-19 18:24:24,772 P5019 [INFO] File "manage.py", line 16, in main
2020-06-19 18:24:24,772 P5019 [INFO] ) from exc
2020-06-19 18:24:24,772 P5019 [INFO] 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?
让我相信问题在于我的虚拟环境无法激活。一些在线研究告诉我激活venv的命令应该是
opt/python/run/venv/bin/activate
我试图通过eb-ssh激活它,但没有成功,我收到了消息
bash: opt/python/run/venv/bin/activate: No such file or directory
当我检查opt目录时,由于缺少python文件夹,这一点得到了证实。我不知道为什么虚拟环境不存在/无法被激活,如果您能提供帮助,我将不胜感激
事实证明,我的应用程序是为amazon linux 1和;二,;环境是AmazonLinux2
我不得不将我的环境降级为AL1 python 3.6,并将应用程序中的一些设置还原为AL1(例如wsgi路径)
它现在已启动并运行:)
试试这个:
不要在“激活它”中思考,只需从venv运行python即可
相关问题 更多 >
编程相关推荐