OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.9k stars 2.55k forks source link

GDAL missing librarys on Amazon Linux 2.9.5 with GeoDjango Web Application #2258

Closed Zalkota closed 4 years ago

Zalkota commented 4 years ago

I’m installing GDAL on a Amazon Elastic Beanstalk EC2 and try to run a GeoDjango web application, but it returns an error about missing C library’s. Which is very odd. I’m installing the GDAL, Geos, Proj4 libraries from source via this guide and they are being stored in /usr/local/geos, /usr/local/gdal, /usr/local/proj4 on the EC2.

Environment Paths on AWS EC2: $LD_Library: /usr/local/proj4/lib:/usr/local/geos/lib:/usr/local/gdal/lib:$LD_LIBRARY_PATH

$GDAL_LIBRARY_PATH: /usr/local/gdal/lib/libgdal.so

Expected behavior and actual behavior.

Expected behavior: Django GeoDjango web application runs as it does in my Ubuntu 18 environment.

actual behavior:

Error: OSError: libjson-c.so.3: cannot open shared object file: No such file or directory

[Wed Feb 19 20:21:43.181517 2020] [:error] [pid 23813]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
[Wed Feb 19 20:21:43.181521 2020] [:error] [pid 23813]     from django.contrib.gis.gdal.driver import Driver
[Wed Feb 19 20:21:43.181526 2020] [:error] [pid 23813]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
[Wed Feb 19 20:21:43.181529 2020] [:error] [pid 23813]     from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
[Wed Feb 19 20:21:43.181535 2020] [:error] [pid 23813]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
[Wed Feb 19 20:21:43.181538 2020] [:error] [pid 23813]     from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
[Wed Feb 19 20:21:43.181544 2020] [:error] [pid 23813]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 47, in <module>
[Wed Feb 19 20:21:43.181547 2020] [:error] [pid 23813]     lgdal = CDLL(lib_path)
[Wed Feb 19 20:21:43.181552 2020] [:error] [pid 23813]   File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
[Wed Feb 19 20:21:43.181556 2020] [:error] [pid 23813]     self._handle = _dlopen(self._name, mode)
[Wed Feb 19 20:21:43.181594 2020] [:error] [pid 23813] OSError: libjson-c.so.3: cannot open shared object file: No such file or directory
[Wed Feb 19 20:21:44.772958 2020] [:error] [pid 23847] handling WSGI exception
[Wed Feb 19 20:21:44.813255 2020] [:error] [pid 23847] Traceback (most recent call last):
[Wed Feb 19 20:21:44.813434 2020] [:error] [pid 23847]   File "/opt/python/current/app/mysite/mysite/wsgi.py", line 22, in <module>
[Wed Feb 19 20:21:44.813442 2020] [:error] [pid 23847]     application = get_wsgi_application()
[Wed Feb 19 20:21:44.813450 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Feb 19 20:21:44.813464 2020] [:error] [pid 23847]     django.setup(set_prefix=False)
[Wed Feb 19 20:21:44.813471 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Wed Feb 19 20:21:44.813475 2020] [:error] [pid 23847]     apps.populate(settings.INSTALLED_APPS)
[Wed Feb 19 20:21:44.813481 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
[Wed Feb 19 20:21:44.813484 2020] [:error] [pid 23847]     app_config.import_models()
[Wed Feb 19 20:21:44.813489 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
[Wed Feb 19 20:21:44.813496 2020] [:error] [pid 23847]     self.models_module = import_module(models_module_name)
[Wed Feb 19 20:21:44.813501 2020] [:error] [pid 23847]   File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Wed Feb 19 20:21:44.813504 2020] [:error] [pid 23847]     return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 19 20:21:44.813510 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Wed Feb 19 20:21:44.813515 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Wed Feb 19 20:21:44.813521 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Wed Feb 19 20:21:44.813527 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Wed Feb 19 20:21:44.813532 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
[Wed Feb 19 20:21:44.813538 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Wed Feb 19 20:21:44.813556 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/modelcluster/models.py", line 153, in <module>
[Wed Feb 19 20:21:44.813560 2020] [:error] [pid 23847]     class ClusterableModel(models.Model):
[Wed Feb 19 20:21:44.813565 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/base.py", line 114, in __new__
[Wed Feb 19 20:21:44.813568 2020] [:error] [pid 23847]     new_class.add_to_class('_meta', Options(meta, app_label))
[Wed Feb 19 20:21:44.813573 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/base.py", line 315, in add_to_class
[Wed Feb 19 20:21:44.813576 2020] [:error] [pid 23847]     value.contribute_to_class(cls, name)
[Wed Feb 19 20:21:44.813582 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/options.py", line 205, in contribute_to_class
[Wed Feb 19 20:21:44.813586 2020] [:error] [pid 23847]     self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Feb 19 20:21:44.813591 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
[Wed Feb 19 20:21:44.813594 2020] [:error] [pid 23847]     return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Feb 19 20:21:44.813599 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/utils.py", line 202, in __getitem__
[Wed Feb 19 20:21:44.813602 2020] [:error] [pid 23847]     backend = load_backend(db['ENGINE'])
[Wed Feb 19 20:21:44.813607 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
[Wed Feb 19 20:21:44.813610 2020] [:error] [pid 23847]     return import_module('%s.base' % backend_name)
[Wed Feb 19 20:21:44.813615 2020] [:error] [pid 23847]   File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Wed Feb 19 20:21:44.813618 2020] [:error] [pid 23847]     return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 19 20:21:44.813627 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Wed Feb 19 20:21:44.813632 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Wed Feb 19 20:21:44.813638 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Wed Feb 19 20:21:44.813643 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Wed Feb 19 20:21:44.813649 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
[Wed Feb 19 20:21:44.813654 2020] [:error] [pid 23847]   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Wed Feb 19 20:21:44.813660 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 6, in <module>
[Wed Feb 19 20:21:44.813663 2020] [:error] [pid 23847]     from .features import DatabaseFeatures
[Wed Feb 19 20:21:44.813671 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
[Wed Feb 19 20:21:44.813674 2020] [:error] [pid 23847]     from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
[Wed Feb 19 20:21:44.813680 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
[Wed Feb 19 20:21:44.813683 2020] [:error] [pid 23847]     from django.contrib.gis.db.models import aggregates
[Wed Feb 19 20:21:44.813689 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
[Wed Feb 19 20:21:44.813692 2020] [:error] [pid 23847]     import django.contrib.gis.db.models.functions  # NOQA
[Wed Feb 19 20:21:44.813697 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
[Wed Feb 19 20:21:44.813700 2020] [:error] [pid 23847]     from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
[Wed Feb 19 20:21:44.813705 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
[Wed Feb 19 20:21:44.813708 2020] [:error] [pid 23847]     from django.contrib.gis import forms, gdal
[Wed Feb 19 20:21:44.813713 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
[Wed Feb 19 20:21:44.813716 2020] [:error] [pid 23847]     from .fields import (  # NOQA
[Wed Feb 19 20:21:44.813721 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
[Wed Feb 19 20:21:44.813724 2020] [:error] [pid 23847]     from django.contrib.gis.geos import GEOSException, GEOSGeometry
[Wed Feb 19 20:21:44.813729 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/geos/__init__.py", line 5, in <module>
[Wed Feb 19 20:21:44.813733 2020] [:error] [pid 23847]     from .collections import (  # NOQA
[Wed Feb 19 20:21:44.813738 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/geos/collections.py", line 9, in <module>
[Wed Feb 19 20:21:44.813741 2020] [:error] [pid 23847]     from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
[Wed Feb 19 20:21:44.813746 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/geos/geometry.py", line 8, in <module>
[Wed Feb 19 20:21:44.813749 2020] [:error] [pid 23847]     from django.contrib.gis import gdal
[Wed Feb 19 20:21:44.813754 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
[Wed Feb 19 20:21:44.813760 2020] [:error] [pid 23847]     from django.contrib.gis.gdal.datasource import DataSource
[Wed Feb 19 20:21:44.813766 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
[Wed Feb 19 20:21:44.813769 2020] [:error] [pid 23847]     from django.contrib.gis.gdal.driver import Driver
[Wed Feb 19 20:21:44.813775 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
[Wed Feb 19 20:21:44.813778 2020] [:error] [pid 23847]     from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
[Wed Feb 19 20:21:44.813783 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
[Wed Feb 19 20:21:44.813786 2020] [:error] [pid 23847]     from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
[Wed Feb 19 20:21:44.813791 2020] [:error] [pid 23847]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 47, in <module>
[Wed Feb 19 20:21:44.813794 2020] [:error] [pid 23847]     lgdal = CDLL(lib_path)
[Wed Feb 19 20:21:44.813799 2020] [:error] [pid 23847]   File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
[Wed Feb 19 20:21:44.813802 2020] [:error] [pid 23847]     self._handle = _dlopen(self._name, mode)
[Wed Feb 19 20:21:44.813838 2020] [:error] [pid 23847] OSError: libjson-c.so.3: cannot open shared object file: No such file or directory

Steps to reproduce the problem.

Apache attempts to run my Django Application (Which runs successfully on Ubuntu 18), apache returns the missing library error

Operating system

Amazon Linux Python 2.9.5 Elastic Beanstalk EC2

GDAL version and provenance

GDAL_VERSION=2.4.4 GEOS_VERSION=3.6.4 PROJ4_VERSION=5.2.0

Stored in /usr/local/gdal, /usr/local/geos, /usr/local/proj4.

mloskot commented 4 years ago

I’m installing the GDAL, Geos, Proj4 libraries from source ...

Then why you install PROJ and GEOS (headers, etc.) from the packages too?

sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel s3cmd

I may be missing something, but that script does not do anything about GDAL itself, no build steps, just bundling build output:

cd /usr/local/gdal
tar zcvf "/tmp/gdal-${GDAL_VERSION}.tar.gz" *

Finally, I don't think this is GDAL issue at all, but it seems to be GeoDjango, Linux distribution or environment specific configuration issue.

rouault commented 4 years ago

I don't think this is GDAL issue at all

me too. Closing on that basis