Joost Döbken
Joost Döbken

Reputation: 4017

Permanently define environment variable (for Python gdal undefined symbol)

I have installed gdal version 1.11.2, however I have problems with undefined symbols. A proposed solution for this is given by gerrit:

export LD_PRELOAD=/usr/local/lib/libgdal.so.1

However, this only works if I call the python script from the command line. If I call the script from a subprocess.Popen, this will obviously not work.

Is there a way to define the LD_PRELOAD permanently?

Upvotes: 1

Views: 454

Answers (2)

Serge Ballesta
Serge Ballesta

Reputation: 148965

The best solution IMHO is to fix the problem at OS level. If you want gdalto be accessible to only some users of your platform, each user should add the line

export LD_PRELOAD=/usr/local/lib/libgdal.so.1

in his own .profile file (assuming they all use bash or a compatible shell)

Alternatively, if all users should be able to use gdal, that line should be added to the system /etc/profile file.

Upvotes: 1

Serbitar
Serbitar

Reputation: 2224

you can save the export in your /etc/environment if you want to have it globally for every user

or you can use the env argument like so:

subprocess.Popen(command, env={'LD_PRELOAD': '/usr/local/lib/libgdal.so.1'})

see also here: Python subprocess/Popen with a modified environment

Upvotes: 1

Related Questions