Skip to content
Advertisement

GeoDjango GEOSException error

Trying to install a GeoDjango on my machine. I’m really new to Python and being brought into a project that has been a very tricky install for the other team members. I installed Python 2.7 and GEOS using brew, and running PSQL 9.2.4 but keep getting this error when I try to get the webserver running:

JavaScript

Cant seem to find anything relevant to this trace on SO or the web. I think it might be a regex failure? I’m currently trying to reinstall PSQL and GEOS to see if I can get it running.

Here is my requirements file:

JavaScript

Advertisement

Answer

This is my solution (obviously it is ugly, like my English, but works). The problem is that the versions string has an white space unwanted in the RegEx.

The error says:

GEOSException: Could not parse version info string “3.4.2-CAPI-1.8.2 r3921”

And the geos_version_info warns:

Regular expression should be able to parse version strings such as ‘3.0.0rc4-CAPI-1.3.3’, ‘3.0.0-CAPI-1.4.1’ or ‘3.4.0dev-CAPI-1.8.0’

Edit this file: site-packages/django/contrib/gis/geos/libgeos.py

Look for the function: geos_version_info

And change this line:

ver = geos_version().decode()

With this line:

ver = geos_version().decode().split(' ')[0]

There is also another problem, where there is a whitespace at the end but no more information is provided. Such version also doesn’t match version regular expression, so strip()-ping the version may be expected behaviour as a quick fix. In my example it was: '3.8.0-CAPI-1.13.1 '

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement