安装 Graphite 时出现 Django 错误 - settings.DATABASES 配置不正确。请提供 ENGINE 值
Posted
技术标签:
【中文标题】安装 Graphite 时出现 Django 错误 - settings.DATABASES 配置不正确。请提供 ENGINE 值【英文标题】:Django error when installing Graphite - settings.DATABASES is improperly configured. Please supply the ENGINE value 【发布时间】:2012-04-08 16:26:11 【问题描述】:我正在尝试在 ubuntu 上安装 GRAPHITE。我按照博客中的说明进行操作。
http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
当我到达运行命令的部分时..我收到以下错误。我对如何解决零线索。我使用的是最新版本的 Django 1.4。
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
sudo python manage.py syncdb
/opt/graphite/webapp/graphite/thirdparty/pytz/__init__.py:32: UserWarning: Module pytz was already imported from /opt/graphite/webapp/graphite/thirdparty/pytz/__init__.pyc, but /usr/local/lib/python2.7/dist-packages/pytz-2012b-py2.7.egg is being added to sys.path
from pkg_resources import resource_stream
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 459, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
在 /opt/graphite/webapp/graphite/settings.py 文件中,这是内容。
#Database settings, sqlite is intended for single-server setups
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = STORAGE_DIR + 'graphite.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
DASHBOARD_CONF = join(CONF_DIR, 'dashboard.conf')
GRAPHTEMPLATES_CONF = join(CONF_DIR, 'graphTemplates.conf')
【问题讨论】:
【参考方案1】:graphite version 0.9.10 supports Django 1.4... 但是他们将 sqlite 设置放在 django 的 local_settings.py
[mpenning@tsunami graphite]$ cat local_settings.py|grep -v \#
DATABASES =
'default':
'NAME': '/opt/graphite/storage/graphite.db',
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
[mpenning@tsunami graphite]$
[mpenning@tsunami graphite]$ pwd
/opt/graphite/webapp/graphite
[mpenning@tsunami graphite]$
【讨论】:
【参考方案2】:您需要编辑settings.py
并将DATABASES
变量的内容设置为非空字符串。旁边有 cmets 告诉你支持哪些数据库引擎:
DATABASES =
'default':
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # 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.
如果您没有安装其他任何东西,您可以将sqlite3
附加到ENGINE
字符串中,这便于在本地计算机上进行开发。
【讨论】:
你使用的是什么版本的 Django?您的设置文件中有多个DATABASE_
变量(这是旧方法),而您的 Django 似乎正在寻找 DATABASES
变量(这是配置数据库设置的新方法)。
已解决...我删除了 django 1.4 并使用 sudo apt-get install python-django 安装。我猜石墨不喜欢 1.4【参考方案3】:
对于登陆这里并显示错误消息“SECRET_KEY 设置不能为空”的用户,请确保在 /opt/graphite/webapp/graphite/app_settings.py 以及您的 django 配置中设置密钥。
【讨论】:
【参考方案4】:我只是将DATABASES字典添加到文件末尾,它可以工作。我希望graphite可以基于Django 1.4.1运行
【讨论】:
以上是关于安装 Graphite 时出现 Django 错误 - settings.DATABASES 配置不正确。请提供 ENGINE 值的主要内容,如果未能解决你的问题,请参考以下文章
安装 Django-toolbelt 时出现 python_setup.py 和 egg.info 错误
Django - 在 javascript 函数中使用 和 % % 标签时出现语法错误