windows virtualenv使用全局包

时间:2010-12-05 06:31:01

标签: python django virtualenv django-nonrel

我有最新版本的virtualenv,django-nonrel,djangotoolbox和django_mongodb_engine。 virtualenv是使用-no-site-packages创建的。

我尝试关注quick start,但在尝试运行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

似乎是尝试使用默认的django安装而不是我的环境django-nonrel安装。

我尝试将set PYTHONPATH =%PYTHONPATH%; C:\ path \添加到\ env \ Lib \ site-packages \ django但没有更改。

为什么在这里使用默认django安装的任何想法?

3 个答案:

答案 0 :(得分:2)

问题在于Windows下的文件关联。我试图通过“manage.py syncdb”syncdb,它使用默认的Windows python安装。使用“python manage.py syncdb”使用了正确的python和环境。

答案 1 :(得分:1)

您是否尝试过activate.bat

另外,我认为设置PYTHONPATH应该可以工作,但你必须在beggining插入新路径,它应该是包含django instalation的目录的路径,而不是django本身:

set PYTHONPATH=C:\path\to\env\Lib\site-packages\;%PYTHONPATH%

答案 2 :(得分:0)

这是我对这个问题的2美分:

使用PyDev作为eclipse插件,只需指向要与新项目一起使用的新解释器即可解决此问题。

相关问题