繁体   English   中英

在 Elastic Beanstalk 上部署时找不到模块 Django

[英]Cant find module Django while deploying on Elastic Beanstalk

我正在尝试在 Elastic Beanstalk 上部署此存储库https://github.com/LaunchKit/LaunchKit的后端。 我对 Django 非常陌生,我成功完成了这两个教程,解释了如何在 Elastic Beanstalk 上部署 Django: http : //docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html https ://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/

我一直收到消息 ImportError: No module named 'django'

这是位于文件夹“firekit”中的文件结构的一部分

├── LICENSE
├── README.md
├── backend
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── celery_app.py
│   ├── celery_app.pyc
│   ├── lk
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── logic
│   │   ├── migrations
│   │   ├── models
│   │   ├── oauth_middleware.py
│   │   ├── oauth_middleware.pyc
│   │   ├── tasks.py
│   │   ├── templates
│   │   ├── templatetags
│   │   ├── urls.py
│   │   ├── urls.pyc
│   │   └── views
│   ├── manage.py
│   ├── middleware.py
│   ├── middleware.pyc
│   ├── requirements.txt
│   ├── settings.py
│   ├── settings.pyc
│   ├── site_media
│   │   └── images -> ../../skit/lk/__static__/images
│   ├── templates
│   │   └── robots.txt
│   ├── urls.py
│   ├── urls.pyc
│   ├── util
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── bitwise.py
│   │   ├── bitwise.pyc
│   │   ├── cryptoid.py
│   │   ├── cryptoid.pyc
│   │   ├── dnsutil.py
│   │   ├── dnsutil.pyc
│   │   ├── enum.py
│   │   ├── enum.pyc
│   │   ├── environment_loader.py
│   │   ├── hstore_field.py
│   │   ├── hstore_field.pyc
│   │   ├── html_to_text.py
│   │   ├── html_to_text.pyc
│   │   ├── lkforms.py
│   │   ├── lkforms.pyc
│   │   ├── multipart.py
│   │   ├── text.py
│   │   ├── text.pyc
│   │   ├── urlutil.py
│   │   ├── urlutil.pyc
│   │   ├── urlviews.py
│   │   └── urlviews.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── devproxy.go
├── frontend_firekit
│   ├── JSXTransformer.js
│   ├── app.js
│   ├── lk
│   │   ├── __static__
│   │   ├── library
│   │   ├── public
│   │   ├── public_hosted
│   │   └── third_party
│   ├── node_modules
│   │   ├── accepts
│   │   ├── acorn
│   │   ├── align-text
│   │   ├── amdefine
│   │   ├── ansi-regex
│   │   ├── ansi-styles
│   │   ├── asn1
│   │   ├── assert-plus
│   │   ├── async
│   │   ├── aws-sign2
│   │   ├── aws4
│   │   ├── bcrypt-pbkdf
│   │   ├── bl
│   │   ├── body-parser
│   │   ├── boom
│   │   ├── bytes
│   │   ├── camelcase
│   │   ├── caseless
│   │   ├── center-align
│   │   ├── chalk
│   │   ├── cliui
│   │   ├── combined-stream
│   │   ├── commander
│   │   ├── compressible
│   │   ├── compression
│   │   ├── connect
│   │   ├── content-type
│   │   ├── cookies
│   │   ├── core-util-is
│   │   ├── cryptiles
│   │   ├── dashdash
│   │   ├── debug
│   │   ├── decamelize
│   │   ├── delayed-stream
│   │   ├── depd
│   │   ├── destroy
│   │   ├── ecc-jsbn
│   │   ├── ee-first
│   │   ├── escape-html
│   │   ├── escape-string-regexp
│   │   ├── etag
│   │   ├── eventemitter3
│   │   ├── extend
│   │   ├── extsprintf
│   │   ├── finalhandler
│   │   ├── forever-agent
│   │   ├── form-data
│   │   ├── fresh
│   │   ├── generate-function
│   │   ├── generate-object-property
│   │   ├── getpass
│   │   ├── graceful-readlink
│   │   ├── handlebars
│   │   ├── har-validator
│   │   ├── has-ansi
│   │   ├── hawk
│   │   ├── hoek
│   │   ├── http-errors
│   │   ├── http-proxy
│   │   ├── http-signature
│   │   ├── iconv-lite
│   │   ├── inherits
│   │   ├── is-buffer
│   │   ├── is-my-json-valid
│   │   ├── is-property
│   │   ├── is-typedarray
│   │   ├── isarray
│   │   ├── isstream
│   │   ├── jodid25519
│   │   ├── jsbn
│   │   ├── json-schema
│   │   ├── json-stringify-safe
│   │   ├── jsonpointer
│   │   ├── jsprim
│   │   ├── keygrip
│   │   ├── kind-of
│   │   ├── lazy-cache
│   │   ├── lodash
│   │   ├── longest
│   │   ├── media-typer
│   │   ├── mime
│   │   ├── mime-db
│   │   ├── mime-types
│   │   ├── minimist
│   │   ├── ms
│   │   ├── negotiator
│   │   ├── node-uuid
│   │   ├── oauth-sign
│   │   ├── on-finished
│   │   ├── on-headers
│   │   ├── optimist
│   │   ├── parseurl
│   │   ├── pinkie
│   │   ├── pinkie-promise
│   │   ├── process-nextick-args
│   │   ├── qs
│   │   ├── range-parser
│   │   ├── raw-body
│   │   ├── readable-stream
│   │   ├── repeat-string
│   │   ├── request
│   │   ├── requires-port
│   │   ├── right-align
│   │   ├── send
│   │   ├── setprototypeof
│   │   ├── skit
│   │   ├── sntp
│   │   ├── source-map
│   │   ├── sshpk
│   │   ├── statuses
│   │   ├── string_decoder
│   │   ├── stringstream
│   │   ├── strip-ansi
│   │   ├── supports-color
│   │   ├── tough-cookie
│   │   ├── tunnel-agent
│   │   ├── tweetnacl
│   │   ├── type-is
│   │   ├── uglify-js
│   │   ├── uglify-to-browserify
│   │   ├── unpipe
│   │   ├── util-deprecate
│   │   ├── utils-merge
│   │   ├── vary
│   │   ├── verror
│   │   ├── window-size
│   │   ├── wordwrap
│   │   ├── xtend
│   │   └── yargs
│   ├── package.json
│   └── settings.js
├── gae
│   ├── app.yaml
│   ├── favicon.ico
│   ├── index.yaml
│   ├── launchkit_images
│   │   ├── __init__.py
│   │   ├── basehandler.py
│   │   ├── blobinternalhandlers.py
│   │   ├── blobpublichandlers.py
│   │   ├── models.py
│   │   └── util.py
│   ├── main.py
│   └── third_party
│       ├── __init__.py
│       └── poster
├── manage.py
├── requirements.txt
├── review_ingester.py
└── venv
    ├── bin
    │   ├── activate
    │   ├── activate.csh
    │   ├── activate.fish
    │   ├── activate_this.py
    │   ├── easy_install
    │   ├── easy_install-2.7
    │   ├── pip
    │   ├── pip2
    │   ├── pip2.7
    │   ├── python
    │   ├── python-config
    │   ├── python2 -> python
    │   ├── python2.7 -> python
    │   └── wheel
    ├── include
    │   └── python2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
    ├── lib
    │   └── python2.7
    └── pip-selfcheck.json

02_python.config

option_settings:
"aws:elasticbeanstalk:application:environment":
  DJANGO_SETTINGS_MODULE: "settings"
  "PYTHONPATH": "/opt/python/current/app:$PYTHONPATH"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: backend/wsgi.py

后端/ wsgi.py

import os
import sys    

sys.path.insert(0, '/opt/python/current/app')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

你知道为什么我一直有“没有名为‘django’的模块”错误消息吗? 非常感谢您的帮助!

编辑

要求.txt

boto==2.38.0
celery[redis]==3.1.17
cssutils==1.0.1
django-bitfield==1.7.1
Django==1.7.3
djorm-pgarray==1.2.0
dnspython==1.12.0
fabric==1.10.1
hiredis==0.1.5
Pillow==3.0.0
premailer==1.3.0
psycopg2==2.5.4
pycrypto==2.6.1
pylint==0.28.0
python-memcached==1.53
redis==2.10.3
requests==2.5.3
sqlalchemy==0.9.8
tweepy==3.3.0
ua-parser==0.3.6

当我在本地运行pip freeze ,它说:

amqp==1.4.9
ansible==2.1.1.0
anyjson==0.3.3
awsebcli==3.7.8
beautifulsoup4==4.1.3
billiard==3.3.0.23
bleach==1.4
blessed==1.9.5
boto==2.38.0
botocore==1.4.61
Cartridge==0.9.4
celery==3.1.17
cement==2.8.2
cffi==1.8.3
colorama==0.3.7
cryptography==1.5.1
cssselect==0.9.1
cssutils==1.0.1
Django==1.7.3
django-bitfield==1.7.1
djorm-pgarray==1.2
dnspython==1.12.0
docker-py==1.7.2
dockerpty==0.4.1
docopt==0.6.2
docutils==0.12
enum34==1.1.6
Fabric==1.10.1
filebrowser-safe==0.3.5
future==0.9.0
gnureadline==6.3.3
grappelli-safe==0.3.12
hiredis==0.1.5
html5lib==0.999
idna==2.1
image==1.2
ipaddress==1.0.17
ipython==2.0.0
Jinja2==2.8
jmespath==0.9.0
kombu==3.0.37
logilab-astng==0.24.3
logilab-common==1.2.2
lxml==3.3.0
MarkupSafe==0.23
matplotlib==1.4.0
mercurial==3.7.1+20160203
Mezzanine==3.1.8
mock==1.0.1
MySQL-python==1.2.5
nose==1.3.4
numpy==1.9.0
oauthlib==0.6.3
pandas==0.14.1
paramiko==2.0.2
pathspec==0.3.4
PIL==1.1.7
Pillow==3.0.0
premailer==1.3.0
psycopg2==2.5.4
pyasn1==0.1.9
pycparser==2.14
pycrypto==2.6.1
pylint==0.28.0
pymongo==2.7
PyMySQL==0.6.2
pyparsing==2.0.2
PyPDF2==1.22
python-dateutil==2.5.3
python-magic==0.4.12
python-memcached==1.53
pytz==2014.4
PyYAML==3.12
queuelib==1.1.1
redis==2.10.3
reportlab==3.1.8
requests==2.9.1
requests-oauthlib==0.4.1
s3cmd==1.6.1
Scrapy==0.22.0
semantic-version==2.5.0
six==1.10.0
SQLAlchemy==0.9.8
texttable==0.8.4
tweepy==3.3.0
tzlocal==1.0
ua-parser==0.3.6
vboxapi==1.0
virtualenv==15.0.3
w3lib==1.5
wcwidth==0.1.7
websocket-client==0.37.0
xhtml2pdf==0.0.6

我尝试了两种配置,但始终遇到相同的错误。

编辑2

仍然有同样的错误

我在 EB 中做了 ssh。 查找站点包。 将找到的所有路径添加到 wsgi.py

/opt/python/run/baselinenv/lib64/python3.4/site-packages
/opt/python/run/baselinenv/lib/python3.4/site-packages
/opt/python/run/venv/lib64/python3.4/site-packages
/opt/python/run/venv/lib/python3.4/site-packages
/usr/lib64/python2.7/site-packages
/usr/lib/python2.7/site-packages
/usr/local/lib64/python3.4/site-packages
/usr/local/lib64/python2.7/site-packages
/usr/local/lib/python3.4/site-packages
/usr/local/lib/python2.7/site-packages

这太旧了,但我正在经历同样的事情。 我发现我的应用程序没有随着我正在部署的更改而更新,原因是因为我在我的文件夹中使用了 git 并且我没有提交这些更改,因此部署继续部署以前提交的代码。

以防万一有人正在经历我今天经历的同一个兔子洞。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM