postgis isn't an available database backend

1,436 views
Skip to first unread message

klau...@gmail.com

unread,
Feb 23, 2016, 6:24:44 AM2/23/16
to geodjango
Hello, I am seting up geodjango in an amazon EC2 machine plus an amazon postgres RDS database server.

There was a django app working fine, but when configured geodjango this error raised.

  • I installed POSTGIS, GEOS and PROJ.4 libraries in the django server.
  • The EC2 server has no postgres in it, the database is in another machine (amazon RDS), there, I installed postgis as described in here.
  • My settings.py contains:
INSTALLED_APPS = (... 'django.contrib.gis', ... 'django.contrib.admin', ...)

GEOS_LIBRARY_PATH = '/usr/local/lib/libgeos_c.so'

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        ...

The error details:

  File "/opt/django/myvirtualenv_solutions/myvirtualenv_solutions/wsgi.py", line 14, in <module>
    application = get_wsgi_application()
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/models/base.py", line 108, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/models/base.py", line 299, in add_to_class
    value.contribute_to_class(cls, name)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/models/options.py", line 263, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/__init__.py", line 36, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/utils.py", line 212, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/utils.py", line 135, 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:
    'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: /opt/virtualenvs/myvirtualenv/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add
Traceback (most recent call last):
  File "/opt/virtualenvs/myvirtualenv/lib/python3.4/site-packages/django/db/utils.py", line 116, in load_backend
    return import_module('%s.base' % backend_name)

Any guess what I'm missing? Thanks

Claude Paroz

unread,
Feb 23, 2016, 8:32:25 AM2/23/16
to geod...@googlegroups.com
Looking around about the "undefined symbol: _PyTraceback_Add" error, it
might be related to the virtualenv (try recreate it) or the python
exectuable version.
I don't think it's Django related.

Claude

Le 23. 02. 16 12:05, klau...@gmail.com a écrit :
> Hello, I am seting up geodjango in an amazon EC2 machine plus an amazon
> postgres RDS database server.
>
> There was a django app working fine, but when configured geodjango this
> error raised.
>
> * I installed POSTGIS, GEOS and PROJ.4 libraries in the django server.
> * The EC2 server has no postgres in it, the database is in another
> machine (amazon RDS), there, I installed postgis as described in
> here
> <http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.PostGIS>.
> * My settings.py contains:
Reply all
Reply to author
Forward
0 new messages