Reputation: 1435
I built a custom QuantLib (for intraday calculations) on my server located at ~/local/
and trying to import QuantLib
in Python from R using reticulate
.
When I load the package, I get ImportError which seems related to the path and LD_LIBRARY_PATH
environment variable.
import QuantLib as ql
# ImportError: libQuantLib.so.1: cannot open shared object file: No such file or directory
I do not see this problem when the python was run from bash with below .bashrc
export PATH=$HOME/local/bin:$PATH
export CPPFLAGS="-I$HOME/local/include"
export LDFLAGS="-L$HOME/local/lib"
export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH
export PATH=~/.local/share/r-miniconda/envs/r-reticulate/bin:$PATH
I have tried setting the above environment variable for R with .Renviron
,
or setting the variable directly from Python with
os.environ["LD_LIBRARY_PATH"] = $HOME/local/lib:$LD_LIBRARY_PATH
But it still raises the above error. What could be the possible reason?
FYI: I'm running on linux server without sudo
privilege, and below is the full error message from R.
>>> import QuantLib
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook
return _run_hook(name, _hook)
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 96, in _run_hook
module = hook()
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 120, in _hook
return _find_and_load(name, import_)
File "/home/ms/.local/share/r-miniconda/envs/r-reticulate/lib/python3.10/site-packages/QuantLib-1.35-py3.10-linux-x86_64.egg/QuantLib/__init__.py", line 19, in <module>
from .QuantLib import *
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook
return _run_hook(name, _hook)
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 96, in _run_hook
module = hook()
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 120, in _hook
return _find_and_load(name, import_)
File "/home/ms/.local/share/r-miniconda/envs/r-reticulate/lib/python3.10/site-packages/QuantLib-1.35-py3.10-linux-x86_64.egg/QuantLib/QuantLib.py", line 10, in <module>
from . import _QuantLib
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook
return _run_hook(name, _hook)
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 96, in _run_hook
module = hook()
File "/usr/local/lib/R/site-library/reticulate/python/rpytools/loader.py", line 120, in _hook
return _find_and_load(name, import_)
ImportError: libQuantLib.so.1: cannot open shared object file: No such file or directory
Upvotes: 0
Views: 31