Created
October 3, 2016 21:26
-
-
Save acdha/ee4e4efee0f47e6953c05b2f060eb4ad to your computer and use it in GitHub Desktop.
Traceback from a crash introduced by a recent Homebrew update when Python ctypes tries to load gdal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Traceback (most recent call last): | |
| File "/Users/cadams/.virtualenvs/wdl/bin/django-admin", line 11, in <module> | |
| sys.exit(execute_from_command_line()) | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line | |
| utility.execute() | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute | |
| django.setup() | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/__init__.py", line 18, in setup | |
| apps.populate(settings.INSTALLED_APPS) | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate | |
| app_config = AppConfig.create(entry) | |
| File "/Users/cadams/.virtualenvs/wdl/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_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module | |
| __import__(name) | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/reversion/__init__.py", line 11, in <module> | |
| from reversion.revisions import default_revision_manager, revision_context_manager, VersionAdapter | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/reversion/revisions.py", line 28, in <module> | |
| from reversion.models import Revision, Version, has_int_pk, pre_revision_commit, post_revision_commit | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/reversion/models.py", line 48, in <module> | |
| class Revision(models.Model): | |
| File "/Users/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/db/models/base.py", line 324, in add_to_class | |
| value.contribute_to_class(cls, name) | |
| File "/Users/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__ | |
| return getattr(connections[DEFAULT_DB_ALIAS], item) | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/db/utils.py", line 241, in __getitem__ | |
| backend = load_backend(db['ENGINE']) | |
| File "/Users/cadams/.virtualenvs/wdl/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_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module | |
| __import__(name) | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/contrib/gis/db/backends/mysql/base.py", line 5, in <module> | |
| from .features import DatabaseFeatures | |
| File "/Users/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/contrib/gis/db/backends/mysql/features.py", line 1, in <module> | |
| from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures | |
| File "/Users/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/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/cadams/.virtualenvs/wdl/lib/python2.7/site-packages/django/contrib/gis/gdal/__init__.py", line 37, in <module> | |
| ctypes.CDLL('/usr/local/lib/libgdal.dylib') | |
| File "/usr/local/Cellar/python/2.7.12_1/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ran into this same issue today and did some digging. For me, the issue was in an older Django app (1.8.12). It appears that the problem arises because of the way that
HAS_GEOSis checked in that version of Django. There, in__init__.pyindjango.contrib.gis.modelshas the following code to check if GEOS is installed:This import causes ctypes to load the
geos_cdynamic library. A short while later,django.contrib.gis.geos.geometryattempts to import something fromdjango.contrib.gis.gdal. That causes ctypes to load thelibgdaldynamic library. Unfortunately, it appears that ifgeosis loaded beforegdalis loaded, thengdalfails to load with the given error.Starting in In Django 1.9 this conditional check was moved and imports were reshuffled in such a way as to fix this problem. I have been unable to reproduce it in a version of Django after 1.9a1.
If you (like me) are forced to keep an older Django, then ensuring that
gdalis loaded by ctypes at any point beforegeosis loaded is sufficient to avoid this error. Adding the block above insettings.pyensures that it is executed before any database setup occurs, which then ensures thatgdalis loaded beforegeosand solves the problem.