I just started getting this error after reinstalling my local environment with the latest from homebrew:
$ ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/rafael/workspace/goodbed/beds/sitecomments/__init__.py", line 5, in <module>
from beds.sitecomments.models import Comment
File "/Users/rafael/workspace/goodbed/beds/sitecomments/models.py", line 1, in <module>
from django_comments.models import Comment as DjangoComment
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django_comments/models.py", line 7, in <module>
from .abstracts import (
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django_comments/abstracts.py", line 18, in <module>
class BaseCommentAbstractModel(models.Model):
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/models/base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/models/options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/utils.py", line 241, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/db/utils.py", line 112, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 8, in <module>
from .features import DatabaseFeatures
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db.models import aggregates
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/db/models/__init__.py", line 7, in <module>
from django.contrib.gis.geos import HAS_GEOS
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/geos/__init__.py", line 15, in <module>
from .geometry import GEOSGeometry, wkt_regex, hex_regex
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.py", line 10, in <module>
from django.contrib.gis.gdal.error import SRSException
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/gdal/__init__.py", line 47, in <module>
from django.contrib.gis.gdal.driver import Driver # NOQA
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import lgdal
File "/Users/rafael/.virtualenvs/goodbed/lib/python2.7/site-packages/django/contrib/gis/gdal/libgdal.py", line 48, in <module>
lgdal = CDLL(lib_path)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/libgdal.dylib, 6): Symbol not found: _GEOSArea
Referenced from: /usr/local/opt/libspatialite/lib/libspatialite.7.dylib
Expected in: flat namespace
in /usr/local/opt/libspatialite/lib/libspatialite.7.dylib
Help?
Have the same issue just did a clean reinstall of macOS and same issue with brew.
My issue has been resolved I was using Postgres.app which had it's own install/configuration of gdal and because I put /Applications/Postgres.app/Contents/Versions/latest/bin in my path.
Running the doctor gave me the following error, removing gdal that I used brew to install fixed the issue.
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Applications/Postgres.app/Contents/Versions/latest/bin/gdal-config
@rebelliard did you by any chance record the steps you took to fix this? I just encountered the same problem, durable across a full uninstall / reinstall of the Homebrew GIS-related packages, and it'd save a bit of time.
This is not a fix but there's some sort of load-time ordering dependency as the crash can be avoided by having ctypes import gdal earlier in the startup process:
https://gist.github.com/acdha/ee4e4efee0f47e6953c05b2f060eb4ad#gistcomment-1889163
Possible candidates for the change which triggered this:
proj rebuild-the-GIS-world update: https://github.com/Homebrew/homebrew-core/pull/5289
Python 2.7.12 in https://github.com/Homebrew/homebrew-core/pull/2452 and a bunch of updates in 003c0563c870766d02620d479be12493a23f61e1, 6b08d86854de8668cb873f8fb27acd61296e19a5, b96027bb69386fe5bfaeefd07cb234d6001b3195, c8807b3021b3a4c903a51d17419198e367d3e423, etc.
I had two versions of libspatialite installed (4.3.0a_3 and 4.3.0a_2) and switched to the older version with brew switch libspatialite 4.3.0a_2. Problem solved for now.
$ brew info libspatialite
libspatialite: stable 4.3.0a (bottled), HEAD
Adds spatial SQL capabilities to SQLite
https://www.gaia-gis.it/fossil/libspatialite/index
/usr/local/Cellar/libspatialite/4.3.0a_2 (30 files, 19.3M)
Poured from bottle on 2016-03-06 at 23:50:11
/usr/local/Cellar/libspatialite/4.3.0a_3 (31 files, 19.5M) *
Poured from bottle on 2016-10-21 at 00:16:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libspatialite.rb
$ brew switch libspatialite 4.3.0a_2
If anyone else runs into this, I just did a rebuild against 682c98237f86945708d24a71cbbc14d50f3d0dd2 to fix this on a few other Macs:
$ brew uninstall libspatialite gdal proj
$ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
$ git checkout 682c98237f86945708d24a71cbbc14d50f3d0dd2
$ HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_BUILD_FROM_SOURCE=1 brew install libspatialite proj gdal
@MikeMcQuaid I left a pointer in #5979 but this issue is also closed. Does it make more sense to open a new issue or to re-open this one?
Does it make more sense to open a new issue or to re-open this one?
@acdha If you can follow the requested steps on the Troubleshooting page and open a new one with that information and reproducible failure instructions that'd be 鉂わ笍
@acdha That fix worked great for me, thank you. Two notes for anyone else trying it out:
fatal: reference is not a tree when I tried to checkout 682c982. This was due to me having a shallow clone of homebrew-core. Removing my homebrew-core directory and re-cloning homebrew-core resolved that issue.$ HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_BUILD_FROM_SOURCE=1 brew install libspatialite proj
$ HOMEBREW_NO_AUTO_UPDATE=1 brew install gdal
Most helpful comment
If anyone else runs into this, I just did a rebuild against 682c98237f86945708d24a71cbbc14d50f3d0dd2 to fix this on a few other Macs:
@MikeMcQuaid I left a pointer in #5979 but this issue is also closed. Does it make more sense to open a new issue or to re-open this one?