dvidmon
dvidmon

Reputation: 11

PL/Python is not able to access system variables (LD_LIBRARY_PATH)

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:

  1. In the postgresql environment file (/etc/postgresql/10/main/environment).
  2. From inside the python code: os.environ['LD_LIBRARY_PATH'] = 'path_to_lib'
  3. From the psql prompt: \setenv LD_LIBRARY_PATH 'path_to_lib'

But so far, nothing worked out.

Upvotes: 1

Views: 134

Answers (0)

Related Questions