[libprelude] Unable to import prelude module in Python session
Added by Sebastian K over 5 years ago
Hello there,
I am trying to use prelude within a Python script to generate alarms. For this I only need libprelude, which - according to your tutorial here ([[https://www.prelude-siem.org/projects/prelude/wiki/InstallingPreludeRequirement]]) - only requires GnuTLS and Python. I installed GnuTLS from source and Python via aptitude. Then I installed libprelude-5.0.0 from the tarball libprelude-5.0.0.tar.gz. In neither of these I got an error.
If I have not misread something here ([[https://www.prelude-siem.org/projects/prelude/wiki/DevelAgentBuilding]]), I should be able to import this in a Python interactive session via
import prelude
Apparently, this doesn't work neither with Python 2.7 nor Python 3.6. I get an 'ImportError'.
My system is Ubuntu 16.04 LTS. I am not using any environment managers like virtualenv or conda. Before doing the installs, I updated my system via
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
I appreciate any help on this issue. I am sure I missed something, like changing my PYTHONPATH.
Thanks!
Replies (5)
RE: [libprelude] Unable to import prelude module in Python session - Added by Antoine LUONG over 5 years ago
Hello,
You probably miss setting the LD_LIBRARY_PATH environment variable to /usr/local/lib (or wherever the libprelude was installed).
Regards
RE: [libprelude] Unable to import prelude module in Python session - Added by Sebastian K over 5 years ago
Hello Antoine,
thank you for the quick response. I set the variable and the error changed from "ImportError" to "ModuleNotFoundError".
What I noticed, however, was that I did not enable the Python bindings beforehand. So I tried to rebuild libprelude with this command:
./configure --enable-easy-bindings --with-python=/usr/bin/python3.6
After running this, I get this output:
configure: creating ./config.status
config.status: creating Makefile
config.status: creating client.conf
config.status: creating global.conf
config.status: creating idmef-client.conf
config.status: creating libprelude-config
config.status: creating libltdl/Makefile
config.status: creating libmissing/Makefile
config.status: creating libmissing/tests/Makefile
config.status: creating m4/Makefile
config.status: creating src/Makefile
config.status: creating src/libprelude.pc
config.status: creating src/libprelude-error/Makefile
config.status: creating src/jsmn/Makefile
config.status: creating src/include/Makefile
config.status: creating src/include/prelude.h
config.status: creating src/include/prelude-inttypes.h
config.status: creating prelude-admin/prelude-adduser
config.status: creating prelude-admin/Makefile
config.status: creating docs/Makefile
config.status: creating docs/api/Makefile
config.status: creating docs/manpages/Makefile
config.status: creating bindings/Makefile
config.status: creating bindings/c++/Makefile
config.status: creating bindings/c++/include/Makefile
config.status: creating bindings/lua/Makefile
config.status: creating bindings/perl/Makefile.PL
config.status: creating bindings/python/Makefile
config.status: creating bindings/python/setup.py
config.status: creating bindings/ruby/Makefile
config.status: creating tests/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default commands
configure: WARNING: unrecognized options: --with-python
*** Dumping configuration ***
- Generate documentation : no
- LUA binding : no
- Perl binding : yes
- Python2.x binding : no
- Python3.x binding : no
- Ruby binding : no
- Easy bindings : yes
The result is the same if I do not use the --with-python option. I think that I would be able to import the module now, but somehow I can't enable Python bindings.
Can you give me another tip, please?
RE: [libprelude] Unable to import prelude module in Python session - Added by Antoine LUONG over 5 years ago
You also need to install the development package (e.g. python-dev) in order to enable the bindings.
RE: [libprelude] Unable to import prelude module in Python session - Added by Sebastian K over 5 years ago
Hello Antoine,
thanks again, I got it to work this way with Python 3.5 and 2.7 .
I installed python-dev and python3.6-dev, but somehow it binds it to Python 3.5. Is there a way to change the configuration to bind it to 3.6 instead?
Thanks in advance!
RE: [libprelude] Unable to import prelude module in Python session - Added by Antoine LUONG over 5 years ago
Did you try the --with-python3=[...] option?