[英]Django / Heroku Deploying - ModuleNotFoundError: "No module named 'django'"
[英]ModuleNotFoundError: No module named 'django' while deploying to ElasticBeanstalk
在線嘗試了多種解決方案,但無法使其正常運行! 基本上我的應用程序已部署,但http響應是“內部服務器錯誤”。 在調查EB日志時,我發現了以下追溯。
[Sat Jun 08 10:28:56.880823 2019] [:error] [pid 4776] [remote 172.31.4.251:180] Traceback (most recent call last):
[Sat Jun 08 10:28:56.880846 2019] [:error] [pid 4776] [remote 172.31.4.251:180] File "/opt/python/current/app/modelforms/modelforms/wsgi.py", line 12, in <module>
[Sat Jun 08 10:28:56.880863 2019] [:error] [pid 4776] [remote 172.31.4.251:180] from django.core.wsgi import get_wsgi_application
[Sat Jun 08 10:28:56.880878 2019] [:error] [pid 4776] [remote 172.31.4.251:180] ModuleNotFoundError: No module named 'django'
[Sat Jun 08 10:29:10.828039 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Target WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py' cannot be loaded as Python module.
[Sat Jun 08 10:29:10.828089 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Exception occurred processing WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py'.
我的requirements.txt放在所有目錄中,但無法識別django模塊。 它似乎還沒有安裝在第一位。 該文件的內容是:
Django==2.2.1
Pillow==6.0.0
pytz==2019.1
sorl-thumbnail==12.5.0
sqlparse==0.3.0
任何幫助表示贊賞。
編輯1:我沒有設置ebextentions,但是當我運行“eb config”時,會出現相同的配置
aws:elasticbeanstalk:container:python:
NumProcesses: '1'
NumThreads: '15'
StaticFiles: /static/=static/
WSGIPath: modelforms/modelforms/wsgi.py
aws:elasticbeanstalk:container:python:staticfiles:
/static/: static/
aws:elasticbeanstalk:environment:
EnvironmentType: LoadBalanced
ExternalExtensionsS3Bucket: null
ExternalExtensionsS3Key: null
LoadBalancerType: application
ServiceRole: aws-elasticbeanstalk-service-role
嘗試將DJANGO_SETTINGS_MODULE和PYTHONPATH添加到配置中
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "modelforms.settings"
"PYTHONPATH": "/opt/python/current/app/modelforms:$PYTHONPATH"
此外,請檢查運行狀況儀表板,並確保在測試之前將其顯示為已部署
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.