问题
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.
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.
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.
回答1:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
- Create an environment and deploy you application to it with eb create:
eb create django-env
Have you created virtual environment ? if yes, what output you get for the command
eb status
.
Or can you list out the steps you have followed to deploy Django app using Elastic Beanstalk ?
Read this documentation : https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html to use the AWS Elastic Beanstalk Python Platform.
回答2:
Found the issue. The requirement.txt file was place in the wrong directory causing Django not to install.
来源:https://stackoverflow.com/questions/52630920/modulenotfounderror-no-module-named-django