I have recently installed PySNMP library on Ubuntu.
I followed the Quick Start procedure with "Fetch SNMP variable" as explained in the link above.
Unfortunately, I keep getting this error:
File "/home/Camille/Desktop/quick_start.py", line 4, in <module>
getCmd(SnmpEngine(),
NameError: name 'getCmd' is not defined
getCmd() is a function and it does exist
This might be a packaging bug in the apt package.
On Mint 17.3 (Ubuntu 14.04), if I create a virtual environment and use pip to install PySNMP, I get version 4.3.2, and this is fine:
>>> from pysnmp.hlapi import *
>>> getCmd
<function getCmd at 0x7f24e6fab0c8>
However, if I install the ubuntu package via apt-get install python-pysnmp4
, I get 4.2.5, and the above code does not work at all. (ImportError: No module named hlapi
)
In my case, the apt package version does not include the hlapi
module.
The file listing of the PySNMP 4.2.5 source code is here: http://pysnmp.cvs.sourceforge.net/viewvc/pysnmp/pysnmp/pysnmp/?pathrev=release_4_2_5_tag
And the file listing of the apt package is here: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/python-pysnmp4/trusty/files/head:/pysnmp/
I don't know why it's missing, but it's either an omission (they forgot the hlapi folder), or some other reason that isn't clear to me.
While this is not the same as your error, it does suggest that there might be other packaging issues. Perhaps the version that you're using is also incomplete in some way.
Bottom line, if you create a virtualenv and use pip
to install PySNMP, you will probably be ok. You might also want to file a bug with the launchpad maintainer.