G
G
GDApsy2014-01-28 01:51:39
Python
GDApsy, 2014-01-28 01:51:39

Modifying the LD_LIBRARY_PATH environment variable of the Python interpreter from a bash script

The following problem appears in the python 2.7+psycopg2+PostgreSQL 9.2 configuration: python cannot load the psycopg2 module because the paths to the PostgreSQL 9.2 libraries are not set in the Python environment variables. As a solution, it is proposed to write a script that is a hook that fires when the local repository changes are uploaded to the Git repository on OpenShift. It should contain the line: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/postgresql92/root/usr/lib64/
This code works quite well if you type it directly into the shell from which you run python. However, as we managed to find out semi-experimentally, semi-theoretically, bash scripts and other programs work with their own instance of the com interpreter. line, and therefore changes to the environment variables made by the hook bash script have no effect on the environment variables of the Python interpreter. Direct modification from a Python script does not work, and this is due to the fact that the interpreter reads the LD_LIBRARY_PATH variable (the loader that launches the interpreter, more precisely) reads this variable once, and then it does not affect the situation.
I did not find access to any .bashrc on OpenShift. The launch of python and its application is tied to git push and is automatic, I would not want to refuse this

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-01-28
@jcmvbkbc

Run your python directly from the script that executed the export command

A
Alexey Ostroverkhov, 2014-01-28
@sharptop

Is it impossible to prescribe this path to libraries in /etc/ld.so.conf?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question