gpt4 book ai didi

python - 在 Django 中为 ubuntu 11.10 设置 Postgresql 9.1 数据库

转载 作者:行者123 更新时间:2023-11-30 23:45:50 25 4
gpt4 key购买 nike


我正在尝试在 Django 1.3 中配置 Postgresql 9.1 。
注意:我在 Ubuntu 11.10 (oneric) 中执行此操作。我还安装了 postgis 1.5 以与 Postgresql 9.1 一起使用

据我所知,我已经安装了所需的所有依赖项。
我阅读了 this 的说明还有博客。

执行以下操作:

python manage.py syncdb

我收到此错误堆栈。

Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/app_directories.py", line 23, in <module>
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError {ProjectName}.{ModuleName}: No module named postgresql.operations

在 local_settings.py 中,我将引擎名称设置为“django.db.backends.postgresql_psycopg2”。

但是引用this之后,我将引擎名称设置为 'django.contrib.gis.db.backends.postgis' ,我得到以下错误堆栈:

    Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/app_directories.py", line 21, in <module>
mod = import_module(app)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/__init__.py", line 3, in <module>
from datawinners.accountmanagement.post_registration_events import ngo_user_created
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/post_registration_events.py", line 3, in <module>
from datawinners.accountmanagement.models import NGOUserProfile
File "/home/jigish/jigbox/dev/mangrove/datawinners/datawinners/../datawinners/accountmanagement/models.py", line 5, in <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 51, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named postgresql.operations

我什至确保,我已经安装了 postgis (Postgresql-9.1-postgis)。

我哪里出错了?我缺少什么?这是我早期使用 Python、Django、Postgresql 和 Postgis 的经历。
请指出网络上任何相关的有用链接。我尝试过谷歌搜索,但到目前为止还没有成功。

感谢和问候

最佳答案

我也遇到了同样的问题。错误的常见来源似乎是 psycopg2 未正确配置。

我发现这些帖子很有帮助:

Unable to syncdb in GeoDjango App

Django/Python Beginner: Error when executing python manage.py syncdb - psycopg2 not found

banging my head on setting up and running geodjango

关于python - 在 Django 中为 ubuntu 11.10 设置 Postgresql 9.1 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9359082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com