How install GDAL in my project Django

aetogithub
PRO

a year ago

I have an active service on Railway, I want to use GeoDjango with Postgis so I can use map functions, but I can't get GDAL installed on the Railway server. In my local everything worked correctly, but when I went to production in Railway, I couldn't get it to work, and I tried with dockerfiles, and apt, runtime, but I couldn't get it to work

I am using the Template of:timescale-postgis

Tengo esto en mi settings.py:

INSTALLED_APPS = [
    ...
    'django.contrib.gis',
    ...
    ]

...
import os
GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH', '/usr/lib/libgdal.so')

Y en mi archivo Procfile lo siguiente:

release: sudo apt-get update && sudo apt-get install -y gdal-bin libgdal-dev libheif-dev libde265-dev libx265-dev
web: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn aetorescue.wsgi

7 Replies

a year ago

can you please share any error or logs that you are receiving?

and please share the service or project ID as well. thank you.


aetogithub
PRO

a year ago

the ID is:c7aa19e7-240f-42b8-9a3d-3531dc9076b2I was receiving many error messages, I was not able to capture all of them, but here I leave one that I did captureI made a rollback in the service so all the changes made were removed, since this service is a test service, so as not to compromise the real project.The errors start as soon as I add 'django.contrib.gis' to my settings.py, I add an example of the error it gives me

I understand that it is a problem when installing a dependency called GDAL, in my location I was able to make it work correctly with these parameters:

if DEBUG:

GDAL_LIBRARY_PATH = "venv\Lib\site-packages\osgeo\gdal304.dll"

GEOS_LIBRARY_PATH = "venv\Lib\site-packages\osgeo\geos_c.dll"

but when moving to production I don't know where those directories are, or how to install themI look forward to your help, if you need more details I will gladly provide them.


aetogithub
PRO

a year ago

GDAL-3.4.3-cp311-cp311-win_amd64.whlIt was with that version of the GDAL that I made the place work

Attachments


a year ago

Looks like you are trying to use windows dependencies here.


aetogithub
PRO

a year ago

No, that dependency is what the project needs, just comment on which dependency you used locally, and I want to know how to install it in RailwayGDAL is a dependency that cannot be installed with a PIP install, since it needs a wheel file, and I don't know how to install that on the Railway system

I'm just trying to give as much context as possible here.


a year ago

That dependency is for windows, you would need to install the linux dependencies.


aetogithub

No, that dependency is what the project needs, just comment on which dependency you used locally, and I want to know how to install it in RailwayGDAL is a dependency that cannot be installed with a PIP install, since it needs a wheel file, and I don't know how to install that on the Railway systemI'm just trying to give as much context as possible here.

rsk-2002
FREE

a month ago

Did you find the solution "How to use GDAL in railway production environment". I am also facing the same issue. If you find any solution pls help

I have tried this in production

if ENVIRONMENT == "production":
    GDAL_LIBRARY_PATH = "/usr/lib/x86_64-linux-gnu/libgdal.so"
    GEOS_LIBRARY_PATH = "/usr/lib/x86_64-linux-gnu/libgeos_c.so"
    PROJ_LIB = "/usr/share/proj"