I've been trying to create some custom functions in postgresql using PL/Python. However some python libraries import fail because PL/Python has no access to the LD_LIBRARY_PATH variable:
CREATE OR REPLACE FUNCTION pyfunc(smiles text)
RETURNS text
AS $$
from rdkit import Chem
<some code here>
$$ LANGUAGE plpython2u;
In that case, I get an ImportError as the shared object libRDKitRDBoost.so.1 (which is present in the LD_LIBRARY_PATH directory) cannot be found.
I've tried to define LD_LIBRARY_PATH (which is already defined in my bashrc configuration file) in different ways:
- In the postgresql environment file (/etc/postgresql/10/main/environment).
- From inside the python code: os.environ['LD_LIBRARY_PATH'] = 'path_to_lib'
- From the psql prompt: \setenv LD_LIBRARY_PATH 'path_to_lib'
But so far, nothing worked out.