0

我已经安装了 pinax,并创建了一个项目pinax-admin

然后我将该项目复制到一个空的 django-eclipse 项目中,并想从 Eclipse 控制台运行 synchdb,但我只得到:

Traceback (most recent call last):
  File "C:\Users\marcus\Desktop\wseclipse\testpinax\testsite\manage.py", line 20, in <module>
    execute_from_command_line()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "C:\Python27\lib\site-packages\django\core\management\sql.py", line 6, in <module>
    from django.db import models
  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
    self._setup()
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'testpinax.settings' (Is it on sys.path?): No module named testpinax.settings
Finished "manage.py syncdb" execution.

我在我的 postgresql 数据库中创建了表,但是当我想运行该项目时,我得到:

Traceback (most recent call last):
  File "C:\Users\marcus\Desktop\wseclipse\testpinax\testsite\manage.py", line 20, in <module>
    execute_from_command_line()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 8, in <module>
    from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 26, in <module>
    from django.views import static
  File "C:\Python27\lib\site-packages\django\views\static.py", line 95, in <module>
    template_translatable = ugettext_noop(u"Index of %(directory)s")
  File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 75, in gettext_noop
    return _trans.gettext_noop(message)
  File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 48, in __getattr__
    if settings.USE_I18N:
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
    self._setup()
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
**ImportError: Could not import settings 'testpinax.settings' (Is it on sys.path?): No module named testpinax.settings**

但是当我查看我的项目时,您可以看到 settings.py 文件在那里:

在此处输入图像描述

我究竟做错了什么?

PS.:我正在运行 win7、eclipse indigo 和 postgresl 1.16

更新

>>> import sys
>>> print sys.path
['', 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 'C:\\Pytho
n27\\lib\\site-packages\\pip-1.2.1-py2.7.egg', 'C:\\Windows\\system32\\python27.
zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
4

1 回答 1

0

错误消息要求您将testpinax文件夹附加到PYTHONPATH环境变量中,查看wiki 条目以获取有关如何实现该目标的可能解决方案。

问题可能源于您没有从testpinax文件夹启动脚本。

于 2012-10-31T14:31:14.823 回答