Results 1 to 6 of 6

Thread: Python ignores LD_LIBRARY_PATH in openSUSE

  1. #1

    Default Python ignores LD_LIBRARY_PATH in openSUSE

    There is an unexpected behavior of python in openSUSE (at least Leap 42.3 and Leap 15.1).
    I am going to use a python module that needs to load external libraries (pyroot).
    Normally, according to hints on the internet, a path to external libraries is set using LD_LIBRARY_PATH, but in openSUSE python does not try to look for libraries in the folders specified by LD_LIBRARY_PATH at all. I have tried the same for Ubuntu, and it worked as expected. Thus, I suppose it is a SUSE-related problem.
    What should I do to fix this issue?
    In my case the module and all related libraries are located in /usr/local/root/lib.
    Here are some logs:
    Code:
    username@linux-jml8:~> python -c "import ROOT"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/root/lib/ROOT.py", line 24, in <module>
        import cppyy
      File "/usr/local/root/lib/cppyy.py", line 61, in <module>
        import libPyROOT as _backend
    ImportError: libMathCore.so: cannot open shared object file: No such file or directory
    Code:
    username@linux-jml8:~> ls /usr/local/root/lib/ROOT.py
    /usr/local/root/lib/ROOT.py
    username@linux-jml8:~> ls /usr/local/root/lib/libMathCore.so
    /usr/local/root/lib/libMathCore.so
    username@linux-jml8:~> echo $LD_LIBRARY_PATH
    :/usr/local/root/lib
    username@linux-jml8:~> echo $PYTHONPATH
    /usr/local/root/lib
    Code:
    username@linux-jml8:~> strace python -c 'import ROOT' |& grep libMathCore.so
    openat(AT_FDCWD, "/lib64/tls/haswell/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/tls/haswell/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/tls/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/tls/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/haswell/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/haswell/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/lib64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/tls/haswell/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/tls/haswell/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/tls/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/tls/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/haswell/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/haswell/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/x86_64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    openat(AT_FDCWD, "/usr/lib64/libMathCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    ImportError: libMathCore.so: cannot open shared object file: No such file or directory
    As you can see, python does not try to check /usr/local/root/lib for the library, even though it is explicitly stated in LD_LIBRARY_PATH.

  2. #2
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,893
    Blog Entries
    3

    Default Re: Python ignores LD_LIBRARY_PATH in openSUSE

    Quote Originally Posted by xppblbl View Post
    Normally, according to hints on the internet, a path to external libraries is set using LD_LIBRARY_PATH, but in openSUSE python does not try to look for libraries in the folders specified by LD_LIBRARY_PATH at all.
    You are probably misunderstanding how it all works.

    As far as I know, a running program (such as python) just asks the system to load the library module. It is the system that looks at LD_LIBRARY_PATH.

    However, the path can also be preset at compile time with compiler options or by setting LD_RUN_PATH. And that's possibly what happened here.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  3. #3
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,495
    Blog Entries
    2

    Default Re: Python ignores LD_LIBRARY_PATH in openSUSE

    AppArmor settings may be blocking
    https://doc.opensuse.org/documentati...rofiles.exec.m
    https://doc.opensuse.org/documentati...exec.variables

    Or, not sure but you may need to explicitly import your ROOT environment with a fixed path.
    This use of importing custom environmentals is something I haven't had to do often so don't have much experience with it, maybe a review of python environmentals and how to set may be required here...

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  4. #4

    Default Re: Python ignores LD_LIBRARY_PATH in openSUSE

    a running program (such as python) just asks the system to load the library module
    Python interpreter uses its own system of loading libraries. Other programs have no problems with loading the libraries in question.
    the path can also be preset at compile time with compiler options or by setting LD_RUN_PATH
    I would definitely prefer to avoid recompiling python and dozens of dependent packages from sources.
    AppArmor settings may be blocking
    Disabling AppArmor didn't help.
    maybe a review of python environmentals and how to set may be required here
    Even after an extensive search on the internet, the only way I was able to find for python to import a custom path for libraries was via LD_LIBRARY_PATH, that is ignored in openSUSE.

  5. #5
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,893
    Blog Entries
    3

    Default Re: Python ignores LD_LIBRARY_PATH in openSUSE

    I don't know enough about what you are doing to try repeating this. However, I note in your first post:

    Code:
    username@linux-jml8:~> ls /usr/local/root/lib/libMathCore.so
    /usr/local/root/lib/libMathCore.so
    username@linux-jml8:~> echo $LD_LIBRARY_PATH
    :/usr/local/root/lib
    Additionally, you should check:
    Code:
    file /usr/local/root/lib/libMathCore.so
    to make sure that this is the appropriate type of file;

    and
    Code:
    printenv LD_LIBRARY_PATH
    to make sure that this is in your environment, and not just a local shell variable.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  6. #6
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,495
    Blog Entries
    2

    Default Re: Python ignores LD_LIBRARY_PATH in openSUSE

    My references to python environmental paths didn't actually mean to rely on system library paths like LD_LIBRARY_PATH, and wasn't meant to be related to anything related to your basic python install (although through virtualenv is a recommended way), I meant simply importing modules for your specific app.

    Am having problems locating a really good resource describing what I mean, but the following is close
    https://folk.uio.no/jeanra/Informati...thonPaths.html

    But on the topic of using virtualenv, it's something you might consider seriously... It's the standard way Python developers install, maintain and deploy multiple versions of Python side by side on the same system, and of course when you do this you have to closely configure all the libraries and environmental variables to keep them separate.

    I don't see any SUSE/openSUSE documentation on this important subject, but this is one of many generic articles posted online...
    https://kb.iu.edu/d/aonm

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •