Opened 9 years ago

Closed 9 years ago

#23873 closed Cleanup/optimization (fixed)

Trying to import GIS without GEOS installed leads to obscure error message

Reported by: Carl Meyer Owned by: nobody
Component: GIS Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The error message is "cannot import name GEOSException."

Given that we already calculate a HAS_GEOS variable, it would not be hard to issue a clearer message.

Here is an example of a new user being led quite a ways down a rabbit-hole by the confusing message: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/django-users/W3IBOBTQMyU/3F8xBVMAwsYJ

Change History (4)

comment:1 by Claude Paroz, 9 years ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Maybe something like that:

  • django/contrib/gis/db/models/__init__.py

    diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py
    index 835e907..9be4a18 100644
    a b  
     1from django.core.exceptions import ImproperlyConfigured
     2
    13# Want to get everything from the 'normal' models package.
    24from django.db.models import *  # NOQA
    35
     6from django.contrib.gis.geos import HAS_GEOS
     7
     8if not HAS_GEOS:
     9    raise ImproperlyConfigured(
     10        "GEOS is required and has not been detected. Are you sure it is installed? "
     11        "See also https://docs.djangoproject.com/en/stable/ref/contrib/gis/install/geolibs/")
     12
    413# Geographic aggregate functions
    514from django.contrib.gis.db.models.aggregates import *  # NOQA

comment:2 by Carl Meyer, 9 years ago

Yep, that looks pretty reasonable to me.

comment:3 by Carl Meyer, 9 years ago

Created a pull request (https://github.com/django/django/pull/3581) just to get CI verification that this doesn't break anything.

comment:4 by Carl Meyer <carl@…>, 9 years ago

Resolution: fixed
Status: newclosed

In d2bcb0598058dd93eac94bdbb7dd2565cff0abea:

Fixed #23873 -- Improved GIS error message when GEOS is not installed.

Thanks Claude for writing the patch.

Note: See TracTickets for help on using tickets.
Back to Top