Python Forum

Full Version: Cannot import easysnmp: ImportError: libnetsnmp.so.30
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to use easysnmp in a virtual environment, but get an error when I import it:

Output:
(venv) snorton@app7 /fastapi/sv $ python3 Python 3.7.11 (default, Dec 20 2022, 10:51:25) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import easysnmp Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/fastapi/sv/venv/lib/python3.7/site-packages/easysnmp/__init__.py", line 1, in <module> from .easy import ( # noqa File "/fastapi/sv/venv/lib/python3.7/site-packages/easysnmp/easy.py", line 3, in <module> from .session import Session File "/fastapi/sv/venv/lib/python3.7/site-packages/easysnmp/session.py", line 9, in <module> from . import interface ImportError: libnetsnmp.so.30: cannot open shared object file: No such file or directory >>> ---------------------------------------------------------------------------- (venv) snorton@app7 /fastapi/sv $ sudo find / -name libnetsnmp.so* /usr/local/lib/libnetsnmp.so /usr/local/lib/libnetsnmp.so.30 /usr/local/lib/libnetsnmp.so.30.0.3 /usr/lib64/libnetsnmp.so /usr/lib64/libnetsnmp.so.31.0.2 /usr/lib64/libnetsnmp.so.31 ---------------------------------------------------------------------------
Any idea why, and how to fix it?
is /usr/local/lib/ in PATH ?

echo $PATH
(Jun-08-2023, 08:30 PM)Axel_Erfurt Wrote: [ -> ]is /usr/local/lib/ in PATH ?

echo $PATH
$ echo $PATH
/fastapi/sv/venv/bin:/usr/local/openssl/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/snorton/bin:/home/Tools

Looks like it's not. How do I fix this?

I should note that this script will be run by multiple users, including as a cron job, so I can't just add it to my .bash_profile
(Jun-08-2023, 08:36 PM)Calab Wrote: [ -> ]Looks like it's not. How do I fix this?

This seems to have fixed it... it that all that was needed or is this something that will always need to be run?

Output:
sudo ldconfig /usr/local/lib
It could be the variable LD_LIBRARY_PATH