[BUG] Errors in Pyswip.core file when running tests
Dcisowski opened this issue · 6 comments
Problem
When I'm trying to run tests using pytest library I'm encountering bug which you can see below:
test_engine.py:2: in <module>
from deepproblog.engines import ApproximateEngine
../src/deepproblog/engines/__init__.py:1: in <module>
from deepproblog.engines.approximate_engine import ApproximateEngine
../src/deepproblog/engines/approximate_engine.py:2: in <module>
from deepproblog.engines.prolog_engine import (
../src/deepproblog/engines/prolog_engine/__init__.py:1: in <module>
from .engine import PrologEngine
../src/deepproblog/engines/prolog_engine/engine.py:4: in <module>
from pyswip import Prolog
../venv/src/pyswip/pyswip/__init__.py:29: in <module>
from pyswip.prolog import Prolog
../venv/src/pyswip/pyswip/prolog.py:28: in <module>
from pyswip.core import *
../venv/src/pyswip/pyswip/core.py:849: in <module>
PL_mark_string_buffers = _lib.PL_mark_string_buffers
/usr/lib/python3.6/ctypes/__init__.py:361: in __getattr__
func = self.__getitem__(name)
/usr/lib/python3.6/ctypes/__init__.py:366: in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
E AttributeError: /usr/lib/libswipl.so.7.6: undefined symbol: PL_mark_string_buffers
This exact error is happening for all of the test cases.
This error appears in core.py from pyswip library in 849 line of code
PL_mark_string_buffers = _lib.PL_mark_string_buffers
Regarding Python IDE I'm using Pycharm.
I'am using forked version of PySwip alongside with all other necessary libraries:
- ProbLog
- PySDD (installed from source)
- PyTorch
- TorchVision
packages like ProbLog, PyTorch and TorchVision were downloaded using Pycharm package manager. PySDD and PySwip were downloaded from source.
Also what is worth to mention is that I'm trying to run it on venv so all the packages are located inside venv/lib/python3.6/site-packages and PySwip is located inside venv/src
I'm wondering what is the problem here and If you know the cause for this problems and how to fix them i would be grateful for giving me solution.
- OS: Ubuntu 18.04 LTS
- Python Version: Python 3.6
@Dcisowski I suspect that the version of SWIPL may be too old (given the error mentioning libswipl.so.7.6). Is 7.6 the version that you using?
I would suggest if at all possible to update to a newer Ubuntu release so that you can get a newer swipl. 18.04 is quite old by now, and 20.04 LTS has been out for quite a while, and 22.04 LTS is about to be released soon.
Alternatively this is an issue that need to be fixed in pyswip (as opposed to deepproblog) if they want to support older SWI-Prolog versions. This seems unlikely as the README for pyswip states "SWI-Prolog 8.2 and higher." as a requirement.
The third option would be to just update SWIPL or use a docker container or similar to run a newer Ubuntu version in.
I am having the same issue when trying to run the MNIST example. I am using:
Python 3.8
OS: Scientific Linux 7.9 (Nitrogen)
Traceback is below. My error message says libswipl.so.7.6.4, so I will try to update SWI-Prolog and see if that helps.
File "/home/usr/deepproblog/src/deepproblog/examples/MNIST/addition.py", line 7, in <module>
from deepproblog.engines import ApproximateEngine, ExactEngine
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/deepproblog/engines/__init__.py", line 1, in <module>
from deepproblog.engines.approximate_engine import ApproximateEngine
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/deepproblog/engines/approximate_engine.py", line 2, in <module>
from deepproblog.engines.prolog_engine import (
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/deepproblog/engines/prolog_engine/__init__.py", line 1, in <module>
from .engine import PrologEngine
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/deepproblog/engines/prolog_engine/engine.py", line 4, in <module>
from pyswip import Prolog
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/pyswip/__init__.py", line 29, in <module>
from pyswip.prolog import Prolog
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/pyswip/prolog.py", line 28, in <module>
from pyswip.core import *
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/site-packages/pyswip/core.py", line 849, in <module>
PL_mark_string_buffers = _lib.PL_mark_string_buffers
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "/home/usr/miniconda3/envs/dplog_env/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/swipl-7.6.4/lib/x86_64-linux/libswipl.so: undefined symbol: PL_mark_string_buffers```
Have you tried updating to a more recent SWI Prolog version as the comment above suggests?
It seems that Ubuntu 20.04 LTS comes by default with swipl in version 7.6.4. Installing swipl from ppa:swi-prolog/stable
repository allows to upgrade to 8.4.2. See: https://wwu-pi.github.io/tutorials/lectures/lsp/010_install_swi_prolog.html
I would rather suggest looking at the relevant page of the official SWI-Prolog website: https://www.swi-prolog.org/download/stable
I've upgraded to 8.5.11 for x86_64-linux which solved that problem.
I'm having a new problem now which is nearly identical to this one here.
One person has suggested that some pyswip versions have compatibility issues with certain swipl, but deepproblog depends on your pyswip fork. Could you please tell me what version of SWI-Prolog you used when running this?
For context, I am trying to run addition.py for the MNIST example (and have done the pretraining step already). Below is what I get:
[Thread 1 (main) at Wed May 18 13:55:44 2022] ~/swipl-devel/src/pl-fli.c:2556: PL_put_chars: Assertion failed: 0
C-stack trace labeled "assert_fail":
[0] save_backtrace() at /home/s2200046/swipl-devel/src/os/pl-cstack.c:334 [0x7fc6fb7e5315]
[1] __assert_fail() at /home/s2200046/swipl-devel/src/pl-assert.c:103 [0x7fc6fb7861ea]
[2] PL_put_chars() at /home/s2200046/swipl-devel/src/pl-fli.c:2556 (discriminator 1) [0x7fc6fb7b6471]
[3] ffi_call_unix64() at :? [0x7fc75d21b9dd]
[4] ffi_call_int() at ffi64.c:? [0x7fc75d21b067]
[5] _call_function_pointer() at /usr/local/src/conda/python-3.8.13/Modules/_ctypes/callproc.c:942 [0x7fc75d2341e9]
[6] PyCFuncPtr_call() at /usr/local/src/conda/python-3.8.13/Modules/_ctypes/_ctypes.c:4212 [0x7fc75d234c95]
[7] python(_PyObject_MakeTpCall+0x3bf) [0x556c9c0e413f]
[8] python(_PyEval_EvalFrameDefault+0x4eff) [0x556c9c18e89f]
[9] python(+0x197bc5) [0x556c9c14abc5]
[10] python(+0x13b23d) [0x556c9c0ee23d]
[11] python(_PyEval_EvalFrameDefault+0x71b) [0x556c9c18a0bb]
[12] python(_PyEval_EvalCodeWithName+0x260) [0x556c9c17f600]
[13] python(_PyFunction_Vectorcall+0x534) [0x556c9c180b64]
[14] python(+0x166b2e) [0x556c9c119b2e]
[15] python(_PyEval_EvalFrameDefault+0x4f83) [0x556c9c18e923]
[16] python(_PyEval_EvalCodeWithName+0x888) [0x556c9c17fc28]
[17] python(_PyFunction_Vectorcall+0x594) [0x556c9c180bc4]
[18] python(+0x1b9798) [0x556c9c16c798]
[19] python(_PyObject_MakeTpCall+0x228) [0x556c9c0e3fa8]
[20] python(_PyEval_EvalFrameDefault+0x4eff) [0x556c9c18e89f]
[21] python(_PyEval_EvalCodeWithName+0x260) [0x556c9c17f600]
[22] python(_PyFunction_Vectorcall+0x594) [0x556c9c180bc4]
[23] python(+0x1b97da) [0x556c9c16c7da]
[24] python(_PyObject_MakeTpCall+0x228) [0x556c9c0e3fa8]
[25] python(_PyEval_EvalFrameDefault+0x546a) [0x556c9c18ee0a]
[26] python(_PyEval_EvalCodeWithName+0x260) [0x556c9c17f600]
[27] python(PyEval_EvalCode+0x23) [0x556c9c180eb3]
[28] python(+0x242622) [0x556c9c1f5622]
[29] python(+0x2531d2) [0x556c9c2061d2]
[30] python(+0x25636b) [0x556c9c20936b]
[31] python(PyRun_SimpleFileExFlags+0x1bf) [0x556c9c20954f]
[32] python(Py_RunMain+0x3a9) [0x556c9c209a29]
[33] python(Py_BytesMain+0x39) [0x556c9c209c29]
[34] __libc_start_main() at ??:? [0x7fc75da1d0b3]
[35] python(+0x1f9ad7) [0x556c9c1acad7]
Aborted (core dumped)
`