本文介绍了在GeoDjango应用程序中无法syncdb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设置空间数据库并与GeoDjango进行同步时遇到了一个真正的麻烦。我可以根据geodjango文档设置空间数据库,并创建一个django应用程序,但是当我运行

I am having a real trouble in setting up spatial database and syncing it with GeoDjango. I was able to setup the spatial database as per the geodjango documentation and create a django app but when i run

python manage.py sqlall world

我得到这个,

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/commands/sqlall.py", line 4, in <module>
    from django.core.management.sql import sql_all
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in <module>
    from django.db import models
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/db/utils.py", line 44, 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 psycopg2.extensions

我累了,真的不知道该怎么办?请帮助

I am tired and really not sure what to do? Please help

编辑

确定我发现这个哪种告诉我出了什么问题。现在,当我从\home进入 python ,我执行 import psycopg2 它不会给我任何ImportError但是当我在虚拟环境中时,我得到ImportError

Ok I found this link which kind of tells me what went wrong. Now when i get into the python from \home, and i execute import psycopg2 it does not give me any ImportError but when i am inside the virtual env, I get the ImportError

(django-env)smaranh@ubuntu:~/geodjango$ python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named psycopg2

现在链接指导我如何附加路径但是,由于我是新的,我并不真正理解这个过程,我不希望进一步弄清楚。所以有人可以一步一步地指导我如何附加 sys.path ??

Now the link guides me in how to append the path but i am not really understanding the process since I am new and i do not wish to screw it up further. So can somebody pls guide me step by step how to append the sys.path??

推荐答案

如果您使用的是virtualenv,则需要在环境中安装psycopg2,例如:

If you are using virtualenv you need install psycopg2 inside the environment, something like:

pip install psycopg2

但是您需要在之前安装一些apt:

but you need install some packages with apt before that:

sudo apt-get install python-dev postgresql-server-dev-all

这篇关于在GeoDjango应用程序中无法syncdb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 12:14
查看更多