方法1:
pip install pysnmp
直接从网上下载
方法2:
进入如下连接:
https://pypi.python.org/pypi/pysnmp
下载下来安装包:
pysnmp-4.4.4-py2.py3-none-any.whl
拷贝到板子上去,(板子不能连接外网)
执行如下命令:
# pip install pysnmp-4.4.4-py2.py3-none-any.whl
Processing ./pysnmp-4.4.4-py2.py3-none-any.whl
Collecting pycryptodomex (from pysnmp==4.4.4)
/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connection.py:279: SystemTimeWarning: System time is way off (before 2014-01-01). This will probably lead to SSL verification errors
SystemTimeWarning
Could not fetch URL https://pypi.python.org/simple/pycryptodomex/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) - skipping
Could not find a version that satisfies the requirement pycryptodomex (from pysnmp==4.4.4) (from versions: )
No matching distribution found for pycryptodomex (from pysnmp==4.4.4)
方法3:
pysnmp依赖两个第三方的python库:
(1) ASN.1 : Structure of Management Information:管理信息结构
用于定义通过网络管理协议可访问的对象的规则。SMI定义在MIB中使用的数据类型及网络资源在MIB中的名称或表示。
(2) Cryptography Toolkit: 用来加密的。
安装的过程为先安装ASN.1 和Cryptography的python库,最后安装pysnmp。
下载地址:
ASN.1 library for Python:
http://sourceforge.net/projects/pyasn1/files/ 目前的最新版本为:pyasn1-0.1.8.tar.gz
Python Cryptography Toolkit:
http://www.amk.ca/python/code/crypto.html 目前的最新版本为:cryptkit-0.9.tar.gz
PySNMP:
http://sourceforge.net/projects/pysnmp/files/ 目前最新版本为:pysnmp-4.2.5.tar.gz
安装顺序:
(1): ASN.1 library for Python : python setup.py install
(2):Python Cryptography Toolkit : python setup.py install
(3): PySNMP : python setup.py install
测试是否成功:
在Pysnmp解压的目录下有一个example的目录,首先在
\examples\v3arch\agent\cmdrsp\ 下运行 python v1-read-and-write-communities.py
接下来在\examples\v3arch\manager\getgen 下运行 python get-v1.py
出现结果:
1.3.6.1.2.1.1.1.0 = SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m
则说明安装正确了。
方法4:
http://pysnmp.sourceforge.net/download.html
# wget https://bootstrap.pypa.io/ez_setup.py
# python ez_setup.py
$ tar zxf package-X.X.X.tar.gz
$ cd package-X.X.X
# python setup.py install
# cd ..
# rm -rf package-X.X.X