ModuleNotFoundError: No module named 'django

白昼怎懂夜的黑 提交于 2020-06-17 05:34:50

问题


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

  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!