问题描述
我已经使用django在虚拟环境中构建了一个站点,并按照AWS文档中的步骤进行了部署.我已使用Elastic Beanstalk将站点部署到AWS Web服务器,并设置了运行3.6和django 2.1.1的python环境.我已经拉出日志,并收到以下错误:
I have built a site in virtual env using django and have followed the steps from AWS document for deploying the site. I have deployed my site to AWS web server using Elastic Beanstalk and have setup a python environment running 3.6 and django 2.1.1. I have pulled the logs and am getting the following error:
Traceback (most recent call last):
File "/opt/python/current/app/weddingProject/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
Target WSGI script '/opt/python/current/app/weddingProject/wsgi.py' cannot be loaded as Python module.
我读过其他文章,他们说尚未安装django,但是,requirements.txt文件确实将其列为要安装的软件包.因此,我不确定是什么引起了该问题,并且我不知道如何检查服务器以确保已安装.
I have read other posts and they are saying that django is not installed however, the requirements.txt file does have it listed as a package to install. So I am not sure whats causing the issue and I dont know how to check the server to ensure it is installed.
当我运行pip Frozen> requirements.txt时,我确实看到django被列为要安装的软件包.我运行eb deploy,由于某种原因未安装django.
When I run pip freeze > requirements.txt I do see django listed as a package to install. I run eb deploy and for some reason django is not being installed.
推荐答案
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
- 创建一个环境,然后使用eb create将您的应用程序部署到该环境:
eb create django-env
- Create an environment and deploy you application to it with eb create:
eb create django-env
您是否创建了虚拟环境?如果是,您将获得该命令的输出内容eb status
.
Have you created virtual environment ? if yes, what output you get for the commandeb status
.
或者您可以列出使用Elastic Beanstalk部署Django应用程序所遵循的步骤吗?
Or can you list out the steps you have followed to deploy Django app using Elastic Beanstalk ?
阅读此文档: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html 以使用AWS Elastic Beanstalk Python平台.
Read this documentation : https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html to use the AWS Elastic Beanstalk Python Platform.
这篇关于ModuleNotFoundError:没有名为"django"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!