I have a custom module that needs an library through an environment variable to be set correctly, which I am using in a script.
When I export from commandline and run the script, it works fine:
export FOO_LIB=/path/to/lib
python3 myscript.py
However without that, the import foo
in my script throws exception:
ImportError: dlopen(/path/to/site-packages/bar.so, 2): Library not loaded: bar.dylib
In my script I tried
os.environ['FOO_LIB'] = '/path/to/lib'
import FOO
I still get the same error.
Is there a way I can do this in the python script itself without having to use bash export at all?