Closed lukebarone closed 1 year ago
Have you tried the instructions in the Installation Notes section of the README? I think that should solve your issue.
By the way, after reviewing the example, I did notice two other necessary changes, so I updated the example code. After you compile the openssl module, you will need to copy the example again to get it to work.
I copy and pasted the code into main.py
in my working folder, and edited the parameters to match the network device I'm trying to access. Here is the output (issue on line 3):
> python3 -m pip install snmp
Processing /home/luke/.cache/pip/wheels/be/b8/d1/8ff048fa573a9a4d097c64cfac4342a24104f2d1600417a401/snmp-0.3.1-cp38-cp38-linux_x86_64.whl
Requirement already satisfied: cffi>=1.0.0 in /home/luke/.local/lib/python3.8/site-packages (from snmp) (1.15.1)
Requirement already satisfied: pycparser in /home/luke/.local/lib/python3.8/site-packages (from cffi>=1.0.0->snmp) (2.21)
Installing collected packages: snmp
Successfully installed snmp-0.3.1
> python3 main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
from snmp.security.usm.priv import *
File "/home/luke/.local/lib/python3.8/site-packages/snmp/security/usm/priv/__init__.py", line 6, in <module>
from .aes import *
File "/home/luke/.local/lib/python3.8/site-packages/snmp/security/usm/priv/aes.py", line 4, in <module>
from snmp.openssl.aes import ffi, lib
ModuleNotFoundError: No module named 'snmp.openssl'
uname -a
Linux ComputerName 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
apt
reports the latest version of OpenSSL is installed, but I cannot find any lib
or include
directories relating to SSL.
Ohhhh! In that case I think you need to do apt install libssl-dev
Unfortunately, that did not help :(
Running this, then the four commands:
CPPFLAGS="-isystem /usr/include/openssl" LDFLAGS="-W1,rpath,/usr/lib/x86_64-linux-gnu/" python3
Still getting errors.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/luke/.local/lib/python3.8/site-packages/cffi/api.py", line 725, in compile
return recompile(self, module_name, source, tmpdir=tmpdir,
File "/home/luke/.local/lib/python3.8/site-packages/cffi/recompiler.py", line 1564, in recompile
outputfilename = ffiplatform.compile('.', ext,
File "/home/luke/.local/lib/python3.8/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/luke/.local/lib/python3.8/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: LinkError: command 'x86_64-linux-gnu-gcc' failed with exit status 1
did you try uninstalling snmp
and re-installing with pip after installing libssl-dev
?
Yes, I uninstalled with python3 -m pip
, installed libssl-dev
with apt
, then installed snmp
with python3 -m pip install snmp
.
I ran the command from my ~/.local/lib/python3.8/site-packages/snmp directory.
Give it a try from ~/.local/lib/python3.8/site-packages
, outside of the snmp
directory.
Got rid of that error, now an error with the addUser()
part. I'll troubleshoot that part more.
Traceback (most recent call last):
File "main.py", line 11, in <module>
engine.usm.addUser(
AttributeError: 'NoneType' object has no attribute 'addUser'
Great! I was wrong earlier in telling you to use the updated example. If you are using version 0.3.1 (which is the latest version available in pip
), then you need to check out the v0.3.1 tag and use the example from that version of the README (which is probably the same one you copied before).
YES! Working now!
Thanks for your hard work!
Copy and pasted the tutorial from the readme for using SNMPv3. Receiving a ModuleNotFoundError: No module named 'snmp.openssl'.
What can I do or provide to help with this? I have openssl version 1.1.1f-1ubuntu2.16 installed with
apt
(and it's the latest version)