[英]Python Module 'puresnmp' wont load despite being installed
非常不言自明,為 Python 3.7 安裝了“puresnmp”,並確認它在“pip”中列出,但是當我運行我的代碼時,編譯器找不到它。 鑒於其示例代碼,這非常令人沮喪,所以我對該怎么做一無所知。 我對 Python 也很陌生,我知道 Java 和 C 對我來說很陌生。
from puresnmp import get
IP = "127.0.0.1"
COMMUNITY = 'private'
OID = '1.3.6.1.2.1.1.2.0'
result = get(IP, COMMUNITY, OID)
print('''Get Result:
Type: %s
repr: %s
str: %s
''' % (type(result), repr(result), result))
OID = '1.3.6.1.2.1.1.3.0'
result = get(IP, COMMUNITY, OID)
print('''Get Result:
Type: %s
repr: %s
str: %s
''' % (type(result), repr(result), result))
來自https://puresnmp.readthedocs.io/en/latest/cookbook/snmpget.html的代碼它應該只返回我自己的詳細信息,但我從 Visual Studio 代碼得到這個 Z78E6221F6393D1356681DB3:
Traceback (most recent call last):
File "/Users/user/Documents/Code/tempCodeRunnerFile.python", line 1, in <module>
from puresnmp import get
ImportError: No module named puresnmp
有任何想法嗎? 我很想讓這個模塊工作,因為它讀得很好,而且比“pysnmp”之類的東西更容易理解
看起來您沒有選擇正確的 python 解釋器。
請檢查您安裝puresnmp
模塊的位置,以及您選擇了哪個 python 解釋器:
如果要切換 python 解釋器:
You can click on
the name of python interpreter
button at bottom-left of VSCode to select python interpreter Or open the command palette with the shortcut ofCtrl+Shift+P
and execute the command ofPython: Select Interpreter
to select the proper python environment.
或者你可以重新安裝puresnmp
模塊:
使用快捷鍵 Ctrl+Shift+` 創建一個新終端,然后在您選擇的 python 環境中安裝 puresnmp 模塊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.