2

我需要使用 snmp 从我的设备中获取一些信息(端口统计信息、端口描述等),但我正在努力解决一些我没有找到任何答案的包安装错误我正在使用 Windows 10 64 位机器并尝试安装easysnmp包,但我得到以下输出:

> D:\Python36\Scripts>pip.exe install easysnmp
Collecting easysnmp
Using cached easysnmp-0.2.5.tar.gz
Installing collected packages: easysnmp
Running setup.py install for easysnmp ... error
Complete output from command d:\python36\python.exe -u -c "import 
setuptools, 
tokenize;__file__='C:\\Users\\AVISHA~1\\AppData\\Local\\Temp\\pip-
build-9_9zhm70\\easysnmp\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record 
 C:\Users\AVISHA~1\AppData\Local\Temp\pip-wia8b3wa-record\install-
 record.txt --single-version-externally-managed --compile:
'net-snmp-config' is not recognized as an internal or external command,
 operable program or batch file.
 running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\easysnmp
copying easysnmp\compat.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\easy.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\exceptions.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\helpers.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\session.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\utils.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\variables.py -> build\lib.win-amd64-3.6\easysnmp
copying easysnmp\__init__.py -> build\lib.win-amd64-3.6\easysnmp
running build_ext
building 'easysnmp.interface' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\easysnmp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\python36\include -Id:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tceasysnmp/interface.c /Fobuild\temp.win-amd64-3.6\Release\easysnmp/interface.obj -Wno-unused-function
cl : Command line error D8021 : invalid numeric argument '/Wno-unused-function'
*****error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2***** 

Command "d:\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\AVISHA~1\\AppData\\Local\\Temp\\pip-build-9_9zhm70\\easysnmp\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\AVISHA~1\AppData\Local\Temp\pip-wia8b3wa-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\AVISHA~1\AppData\Local\Temp\pip-build-9_9zhm70\easysnmp\

*****error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2***** 
4

2 回答 2

0

恐怕我不能完全回答,因为我只在 Linux 机器上使用过 EasySNMP,但是 Python 的 EasySNMP 模块在下面使用了Net-SNMP;我敢说你需要先下载并安装它(这是我在 Linux 上使用它所必须做的)。

祝你好运!

编辑:对您的帖子的回复引用了一个重复的问题,该问题引用了 EasySNMP Github 上的一个问题,解释说 EasySNMP 不支持 Windows - 抱歉,伙计!你可以试试 PySNMP,我认为那是纯 Python(理论上与平台无关)。

于 2018-06-15T15:59:34.200 回答
0

我在 Windows 10 64 位下成功构建并安装了 EasySNMP 0.2.5。
我采用了一个简单的脚本表单 EasySNMP 页面,但结果好坏参半。
该脚本不适用于命令行。它说:

C:\Python\eLearning>python easytest3.py
Traceback (most recent call last):
  File "easytest3.py", line 2, in <module>
    session = Session(hostname='10.1.7.130', community='public', version=2)
  File "C:\Python\lib\site-packages\easysnmp-0.2.5-py3.8-win-amd64.egg\easysnmp\session.py", 
line 280, in __init__ self.sess_ptr = interface.session(
    easysnmp.exceptions.EasySNMPConnectionError: couldn't create SNMP handle

尽管它可以在 Python 附带的 IDLE 64 位中完美运行。到目前为止,我不知道这是否是库、设置等方面的问题:(

以防万一,

Python 3.8.3、64 位 Net-NSMP 5.7.1

于 2020-07-23T21:03:51.327 回答