GeoDjango GEOSException error

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 '


In the latest GEOS install, the above answer didn't work... but was close to the problem.

I changed the regex right above the geos_version_info(): from:

version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')

to be:

version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+).*$')

Notice the .* added to the end of the regex.