I'm trying to use a python library in my wsgi( apache + flask) based website.
While using the library in a standalone command script, I have to add the library path to LD_LIBRARY_PATH
So this works for standalone script:
# export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
# python script.py
Now when I try to use this python library through Apache+wsgi, I need to pass the same path to apache workers. How can I accomplish that?
Is the library required by a Python module extension you have compiled and installed? If it was, set
LD_RUN_PATH
environment variable to the directory the library is in when compiling and installing that Python module. That way the location is embedded in the Python module extension itself and you don't needLD_LIBRARY_PATH
at run time.The only other way to do it using environment variables is to set
LD_LIBRARY_PATH
in the startup scripts for Apache so that when Apache is started it is set as you require. This means fiddling with system startup scripts so is not ideal or always practical.One final way which may work but isn't really that great of an idea and may not even work, is to use:
in the Apache configuration. This will force linking of the specific library into Apache at startup, but depending on how the library is being used, this may not work.