2

J'ai installé et configuré un Django/MongoDB comme ça!Erreur: Aucun module nommé django_mongodb_engine.base

pip installer virtualenv

source de myproject/bin/activer

pip install + hg https: //bitbucket.org/wkornewald/django-nonrel

pip install hg + https: //bitbucket.org/wkornewald/djangotoolbox

pip installer git + https: //github.com/django-nonrel/mongodb-engine

Toutes ces opérations ont réussi!

maintenant, quand je l'ai changé le fichier settings.py comme la façon suivante:

DATABASES = { 
    'default': { 
     'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': 'mong_db',      # Or path to database file if using sqlite3. 
     'USER': '',      # Not used with sqlite3. 
     'PASSWORD': '',     # Not used with sqlite3. 
     'HOST': '',      # Set to empty string for localhost. Not used with sqlite3. 
     'PORT': '',      # Set to empty string for default. Not used with sqlite3. 
    } 

L'erreur bending se produit:

Error was: No module named django_mongodb_engine.base 

Il est évident que le succès django_mongodb_engine installé. mais pourquoi cette erreur apparaîtra?

btw, Pardonnez mon pauvre anglais!

Répondre

1

Je suis passé par les mêmes étapes que vous avez fait, puis ouvert un shell Python:

$ python 
>>> import django_mongodb_engine.base 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/emptysquare/.virtualenvs/foo/lib/python2.7/site-packages/django_mongodb_engine/base.py", line 4, in <module> 
    from django.db.backends.signals import connection_created 
    File "/Users/emptysquare/.virtualenvs/foo/lib/python2.7/site-packages/django/db/__init__.py", line 14, in <module> 
    if not settings.DATABASES: 
    File "/Users/emptysquare/.virtualenvs/foo/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__ 
    self._setup() 
    File "/Users/emptysquare/.virtualenvs/foo/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup 
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) 
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 

Mais si je fais:

$ DJANGO_SETTINGS_MODULE=settings python 
>>> import django_mongodb_engine.base 

... il fonctionne.

Pouvez-vous définir DJANGO_SETTINGS_MODULE et essayer d'importer django_mongodb_engine.base dans le shell Python?