windows virtualenv using global packages
I have the latest versions of virtualenv,django-nonrel, djangotoolbox and django_mongodb_engine. The virtualenv was created with -no-site-packages.
I attempted to follow the quick start but I see the following errors when trying to run syncdb
Traceback (most recent call last):
File "C:\www\environments\mongotest\djangomongo\manage.py", line 11, in <
module>
execute_manager(settings)
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\__init__.py", line 438, in execute_manager
utility.execute()
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\utils\import
lib.py", line 35, in import_module
__import__(name)
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\commands\syncdb.py", line 7, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\core\managem
ent\sql.py", line 5, in <module>
from django.contrib.contenttypes import generic
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\contrib\cont
enttypes\generic.py", line 6, in <module>
from django.db import connection
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\db\__init__.
py", line 77, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\db\utils.py"
, line 91, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python25\lib\site-packages\django-1.2.3-py2.5.egg\django\db\utils.py"
, line 49, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't an av
ailable database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named django_mongodb_engine.base
It appears to be trying to use the default django installation instead of my environments django-nonrel installation.
I have tried adding set PYTHONPATH=%PYTHONPATH%;C:\path\to\env\Lib\site-packages\django but no 开发者_如何学运维change.
Any ideas why the default django installation is being used here?
The problem was with the file associations under windows. I was trying to syncdb via "manage.py syncdb" which used the default windows python installation. Using "python manage.py syncdb" used the correct python and environment.
Have you tried running activate.bat
?
Also, I think that setting PYTHONPATH should work, but you'd have to insert new path at the beggining, and it should be path to directory containing django instalation, not to django itself:
set PYTHONPATH=C:\path\to\env\Lib\site-packages\;%PYTHONPATH%
here are my 2 cents to this problem:
using PyDev as eclipse plugin, just pointing to new interpreter to be used with new project solves this issue.
精彩评论