cyberdelia / heroku-geo-buildpack

Geo libraries for Heroku
https://github.com/heroku/heroku-geo-buildpack
113 stars 135 forks source link

Not working with Django? #31

Open maroux opened 9 years ago

maroux commented 9 years ago

Tried on both cedar and cedar-14, no luck :(

→ cat .buildpacks 
https://github.com/cyberdelia/heroku-geo-buildpack.git#1.3
https://github.com/heroku/heroku-buildpack-python.git#v60

Deploy looks fine:

remote: =====> Downloading Buildpack: https://github.com/cyberdelia/heroku-geo-buildpack.git
remote: =====> Detected Framework: geos/gdal/proj
remote:        Using geos version: 3.4.2
remote:        Using gdal version: 1.11.1
remote:        Using proj version: 4.8.0_1
remote: -----> Vendoring geo libraries done

On import:

~ $ python
Python 2.7.6 (default, Jul 15 2014, 15:38:10) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.contrib.gis import gdal
/app/.heroku/python/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/__init__.py", line 46, in <module>
    from django.contrib.gis.gdal.driver import Driver  # NOQA
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as capi
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 8, in <module>
    from django.contrib.gis.gdal.libgdal import lgdal
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/libgdal.py", line 48, in <module>
    lgdal = CDLL(lib_path)
  File "/app/.heroku/python/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /app/.heroku/vendor/lib: cannot read file data: Is a directory

In settings.py:

    GEOS_LIBRARY_PATH = os.environ.get('GEOS_LIBRARY_PATH')
    GDAL_LIBRARY_PATH = os.environ.get('GDAL_LIBRARY_PATH')
    PROJ4_LIBRARY_PATH = os.environ.get('PROJ4_LIBRARY_PATH')
--
    DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
ywarezk commented 9 years ago

+1 getting the same thing

pchiquet commented 9 years ago

GeoDjango expects a file in GEOS_LIBRARY_PATH, GDAL_LIBRARY_PATH and PROJ4_LIBRARY_PATH settings, not a directory. (see the doc: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/geolibs/#geoslibrarypath)

So you should write the following lines in settings.py:

from os import environ
GEOS_LIBRARY_PATH = "{}/libgeos_c.so".format(environ.get('GEOS_LIBRARY_PATH'))
GDAL_LIBRARY_PATH = "{}/libgdal.so".format(environ.get('GDAL_LIBRARY_PATH'))
PROJ4_LIBRARY_PATH = "{}/libproj.so".format(environ.get('PROJ4_LIBRARY_PATH'))
aichaous commented 5 years ago

i get the same error even if i added those lines to setting file

aichaous commented 5 years ago

maroux did you solve the problem