IPython: imported module cannot find its shared libraries

In iPython, I import a module, which in turn imports another module. This other module (namely gurobipy) is trying to load its shared library which fails. Added shared library path to LD_LIBRARY_PATH

.bashrc. When I run the whole thing as a script from a shell everything is fine.

I've searched for a while but haven't found a definitive answer to the question: How to install LD_LIBRARY_PATH

in iPython so that imported modules can see it?

I tried os.environ but still got the same error message: ImportError: libgurobi50.so: cannot open shared object file: No such file or directory

EDIT: I am using Ubuntu 13.04.


source to share

2 answers

Try to include LD_LIBRARY_PATH in the system-wide file. For example / etc / profile (at the end). For example, this is what I needed to add for my case:

export NEVESIM_HOME = / home / kam / Applications / Weightless


Be careful with the syntax. Also, you must log in again for the changes to take effect. See https://help.ubuntu.com/community/EnvironmentVariables for details .



The runtime library path is configured when the python interpreter (or IPython) is started. Read this .

It looks like tools like ctypes use this path when looking for libraries. Likewise, if a module depends on a particular library, it will look for that path when imported or run.

This is true for any process, not just IPython. You cannot simply change the bootloader path while the process is running. Also read this .

If you think about it, this is really good. This can cause all sorts of problems. Suddenly, the process cannot find the required library and will crash.

This is unfortunately unfortunate, as it means that IPython really cannot be used as a complete shell replacement.

I'm not sure how shells like BASH are handled. My guess is that BASH uses one execution path for itself and exports another for the processes running inside it.



All Articles