简体   繁体   English

geodjango syncdb错误。来自geodjango教程

[英]geodjango syncdb errors. From geodjango tutorial

I have followed the geodjango installation(windows XP) and tutorial to perfection I am running django 1.2 When I get to syncdb and run I receive the following. 我已经按照geodjango安装(Windows XP)和教程完美我正在运行django 1.2当我进入syncdb并运行时,我收到以下内容。

    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn
an available 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 postgis.base

I tried changing to 'django.db.backends.postgresql_psycopg2' as an alternative But then I receive this response: 我尝试更改为'django.db.backends.postgresql_psycopg2'作为替代方案然后我收到此响应:

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

When I try posgresql: 当我尝试posgresql时:

    **raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No mo
dule named psycopg**

Is it not supposed to be postgis which I successful downloaded and installed? 它不应该是我成功下载和安装的postgis吗? why isn't it working? 为什么不工作? I am new and I am trying to learn so any help would be greatly appreciated. 我是新人,我正在努力学习,所以任何帮助将不胜感激。

The problem is, in settings.py 问题是,在settings.py

'django.db.backends.postgis'

it is supposed to be 它应该是

django.contrib.gis.db.backends.postgis

that should do it. 应该这样做。

I experienced this same error on Mac OS X 10.6 after I followed the instructions on the geodjango site and installed packages using Homebrew. 在我按照geodjango网站上的说明并使用Homebrew安装软件包后,我在Mac OS X 10.6上遇到了同样的错误。 Apparently, the Geodjango documentation gave some incorrect/outdated instructions about how to install it. 显然,Geodjango文档提供了有关如何安装它的一些不正确/过时的说明。 To make Geodjango work, I followed several steps: 为了使Geodjango工作,我遵循了几个步骤:

  1. Right now, GeoDjango 1.4 does not play nice with PostGIS 2.0 (which is the version Homebrew installed when I followed the instructions in the GeoDjango documentation). 目前,GeoDjango 1.4与PostGIS 2.0(当我遵循GeoDjango文档中的说明时安装的Homebrew版本)不太搭配。 So, I needed to install PostGIS 1.5. 所以,我需要安装PostGIS 1.5。 I did this using the following Terminal commands (for this to work, you must have Homebrew installed): 我使用以下终端命令执行此操作(为此,您必须安装Homebrew):

     brew tap homebrew/versions brew install postgis15 brew untap homebrew/versions 
  2. PostGIS 1.5 doesn't play nice with PostGreSQL 9.2 (which is the version Homebrew installed when I followed the Geodjango documentation's instructions). PostGreSQL 9.2(这是我按照Geodjango文档的说明安装的Homebrew版本)不能很好地使用PostGIS 1.5。 So, I installed PostGreSQL 9.1. 所以,我安装了PostGreSQL 9.1。 I forget exactly what Homebrew commands I used to install PostGreSQL 9.1, but they should be similar to the previous step. 我忘记了用于安装PostGreSQL 9.1的Homebrew命令,但它们应该与上一步类似。

  3. In my case the prior steps weren't sufficient to get Geodjango operational. 在我的情况下,先前的步骤不足以让Geodjango运作。 When I tried to run 'syncdb' in Django again, I discovered a new error in Terminal: 当我再次尝试在Django中运行'syncdb'时,我在终端中发现了一个新错误:

     django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No module named psycopg 
  4. I initially thought my copy of psycopg2 and PostgreSQL9.1 were not on my PYHTONPATH, so I added them. 我最初认为我的psycopg2和PostgreSQL9.1的副本不在我的PYHTONPATH上,所以我添加了它们。 I also fiddled around to make sure django was running PostgreSQL 9.1 instead of 9.2. 我也在摆弄以确保django运行PostgreSQL 9.1而不是9.2。 I used 'initdb /usr/local/var/postgres'. 我使用'initdb / usr / local / var / postgres'。

  5. Then I needed to do some database configuration. 然后我需要做一些数据库配置。 I set up a template in PostGIS and set up a "role" (/user) for the database. 我在PostGIS中设置了一个模板,并为数据库设置了“角色”(/ user)。 To do this, I followed the instructions in the Geodjango documentation. 为此,我按照Geodjango文档中的说明进行操作。 I received numerous errors, but Googled them and found solutions pretty easily. 我收到了很多错误,但谷歌搜索他们并很容易找到解决方案。

  6. Then GeoDjango started working properly! 然后GeoDjango开始正常工作!

This source was the most helpful one I found and links to other helpful urls that cover some of these issues in more detail: http://pragmaticstartup.wordpress.com/2012/09/26/installing-django-postgis-postgres-on-os-x-version-hell/ 这个来源是我发现的最有用的来源,并链接到其他有用的网址,更详细地介绍了其中一些问题: http//pragmaticstartup.wordpress.com/2012/09/26/installing-django-postgis-postgres-on -os-X版地狱/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM