Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run test in the python wrapper #12

Open
echalbau opened this issue May 14, 2019 · 3 comments
Open

Unable to run test in the python wrapper #12

echalbau opened this issue May 14, 2019 · 3 comments

Comments

@echalbau
Copy link

Dear all, when i try to run the python test i get the following output (after an apparently successful installation):

sudo python3 setup.py test
running test
tests.test_libmadam (unittest.loader._FailedTest) ... ERROR
tests.test_libmadam_mc (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: tests.test_libmadam (unittest.loader._FailedTest)

ImportError: Failed to import test module: tests.test_libmadam
Traceback (most recent call last):
File "/home/esteban/libmadam-master/python/libmadam_wrapper/init.py", line 28, in
_madam = ct.CDLL("libmadam.so")
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libmadam.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
import(name)
File "/home/esteban/libmadam-master/python/tests/test_libmadam.py", line 19, in
import libmadam_wrapper as madam
File "/home/esteban/libmadam-master/python/libmadam_wrapper/init.py", line 32, in
_madam = ct.CDLL(path)
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libmadam.so.0: cannot open shared object file: No such file or directory

======================================================================
ERROR: tests.test_libmadam_mc (unittest.loader._FailedTest)

ImportError: Failed to import test module: tests.test_libmadam_mc
Traceback (most recent call last):
File "/home/esteban/libmadam-master/python/libmadam_wrapper/init.py", line 28, in
_madam = ct.CDLL("libmadam.so")
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libmadam.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
import(name)
File "/home/esteban/libmadam-master/python/tests/test_libmadam_mc.py", line 19, in
import libmadam_wrapper as madam
File "/home/esteban/libmadam-master/python/libmadam_wrapper/init.py", line 32, in
_madam = ct.CDLL(path)
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libmadam.so.0: cannot open shared object file: No such file or directory


Ran 2 tests in 0.000s

FAILED (errors=2)

How do i fix this?
Thank you in advance.

@keskitalo
Copy link
Member

Is libmadam.so installed in a directory on your LD_LIBRARY_PATH?

@echalbau
Copy link
Author

I am not sure, how do i check that?

@tskisner
Copy link
Member

@echalbau, when python or any program uses the linker to load a shared library, it looks in specific system locations and also in user-defined locations specified (on linux) by the LD_LIBRARY_PATH environment variable. When you install madam you need to choose where you are installing the software and then make sure that this install prefix is in your default search paths. For example, if you install to /home/user/blah, then typically you would do (assuming you use a Bourne-compatible shell):

export PATH=/home/user/blah/bin:$PATH
export LD_LIBRARY_PATH=/home/user/blah/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/home/user/blah/lib/python3.X/site-packages:$PYTHONPATH
(where "X" in the previous line depends on your python version)

Manipulating your shell environment is much more general than installing libmadam, and there are many resources on the internet that are more informative than what I can write here. Whenever you compile and install software to a non-standard location you will have to manipulate your shell environment somehow to find executables, libraries, and python packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants