[Django] #23873: Trying to import GIS without GEOS installed leads to obscure error message

147 views
Skip to first unread message

Django

unread,
Nov 19, 2014, 4:35:54 PM11/19/14
to django-...@googlegroups.com
#23873: Trying to import GIS without GEOS installed leads to obscure error message
--------------------------------------+------------------------
Reporter: carljm | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/23873>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 19, 2014, 4:53:49 PM11/19/14
to django-...@googlegroups.com
#23873: Trying to import GIS without GEOS installed leads to obscure error message
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: GIS | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Maybe something like that:
{{{
#!diff
diff --git a/django/contrib/gis/db/models/__init__.py
b/django/contrib/gis/db/models/__init__.py
index 835e907..9be4a18 100644
--- a/django/contrib/gis/db/models/__init__.py
+++ b/django/contrib/gis/db/models/__init__.py
@@ -1,6 +1,15 @@
+from django.core.exceptions import ImproperlyConfigured
+
# Want to get everything from the 'normal' models package.
from django.db.models import * # NOQA

+from django.contrib.gis.geos import HAS_GEOS
+
+if not HAS_GEOS:
+ raise ImproperlyConfigured(
+ "GEOS is required and has not been detected. Are you sure it is
installed? "
+ "See also
https://docs.djangoproject.com/en/stable/ref/contrib/gis/install/geolibs/")
+
# Geographic aggregate functions
from django.contrib.gis.db.models.aggregates import * # NOQA
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23873#comment:1>

Django

unread,
Nov 19, 2014, 5:02:12 PM11/19/14
to django-...@googlegroups.com
#23873: Trying to import GIS without GEOS installed leads to obscure error message
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: GIS | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by carljm):

Yep, that looks pretty reasonable to me.

--
Ticket URL: <https://code.djangoproject.com/ticket/23873#comment:2>

Django

unread,
Nov 19, 2014, 9:12:33 PM11/19/14
to django-...@googlegroups.com
#23873: Trying to import GIS without GEOS installed leads to obscure error message
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: GIS | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by carljm):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/23873#comment:3>

Django

unread,
Nov 19, 2014, 9:38:07 PM11/19/14
to django-...@googlegroups.com
#23873: Trying to import GIS without GEOS installed leads to obscure error message
--------------------------------------+------------------------------------
Reporter: carljm | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: GIS | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carl Meyer <carl@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"d2bcb0598058dd93eac94bdbb7dd2565cff0abea"]:
{{{
#!CommitTicketReference repository=""
revision="d2bcb0598058dd93eac94bdbb7dd2565cff0abea"
Fixed #23873 -- Improved GIS error message when GEOS is not installed.

Thanks Claude for writing the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23873#comment:4>

Reply all
Reply to author
Forward
0 new messages