2017-07-06 6 views
0

Ich bin neue Programmierung in Django. Ich mache eine lokale Demo und es läuft ohne Probleme, aber der nächste Schritt ist die Bereitstellung der Django-Anwendung auf AWS Elastic Beanstalk, ich versuche das.AWS und Django: "Konnte Django nicht importieren"

Ich habe diese Enviroment: ~/Python_Env/MiEntorno

Und dieses Projekt: ~/ProyectosDjango/Refugio

Meine aktuelle ist Django Projektstruktur folgendermaßen aus:

requirements.txt 
.ebextensions 
    |-01-django_env.config 
.elasticbeanstalk 
    |-config.yml 
.gitignore 
custom_storage.py 
manage.py 
Refugio 
    |__init__.py 
    |-settings 
    |-urls.py 
    |-wsgi.py 
|-apps 
|-templates 
|-static 

Ich habe Dieser Fehler, wenn ich diesen Befehl ausführen: (Mi Entorno)/ProyectosDjango/Refugio> manage.py Collectstatic oder manage.py runserver

"Konnte Django nicht importieren. Sind Sie sicher, dass es unter Ihre PYTHONPATH-Umgebungsvariable installiert und verfügbar ist? ? Haben Sie vergessen, eine virtuelle Umgebung zu aktivieren“

Ich habe dies in meinem -01-django_env.config:

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

und bei der Einrichtung ich die Datenbank bearbeiten und hinzufügen, um diesen:

STATICFILES_LOCATION = 'static' 
MEDIAFILES_LOCATION = 'media' 

AWS_STORAGE_BUCKET_NAME = 's3.refugioprueba.com' 
AWS_ACCESS_KEY_ID = 'xxx' 
AWS_SECRET_ACCESS_KEY = 'yy/xxx/' 

STATICFILES_STORAGE = 'custom_storages.StaticStorage' 
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage' 
AWS_S3_CUSTOM_DOMAIN = '%s.s3-us-west-1.amazonaws.com' % AWS_STORAGE_BUCKET_NAME 
AWS_S3_SECURE_URLS = False 

from boto.s3.connection import ProtocolIndependentOrdinaryCallingFormat 
AWS_S3_CALLING_FORMAT = ProtocolIndependentOrdinaryCallingFormat 
from boto.s3.connection import S3Connection 
S3Connection.DefaultHost = 's3.us.west-1.amazonaws.com' 

STATIC_URL = "http://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION) 
MEDIA_URL = "http://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION) 


WSGI_APPLICATION = 'Refugio.wsgi.application' 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.mysql', 
     'NAME': 'ebdb', 
     'USER': 'root', 
     'PASSWORD': 'XXX', 
     'HOST': 'XXXrds.amazonaws.com', 
     'PORT': 3306, 
    } 
} 

Antwort

0

Sind Sie sicher, dass es in der Umgebung installiert ist? Wie in pip install django (oder welche spezifische Version Sie verwenden)? Oder alternativ pip install -r requirements.txt, wenn es in Ihremist 10 Datei? EBS installiert normalerweise automatisch requirements.txt Abhängigkeiten, so dass es dort die sicherste ist

Verwandte Themen