Python Routeros连接失败

Python Routeros连接失败,python,dictionary,python-requests,router-os,Python,Dictionary,Python Requests,Router Os,我已经在pip中安装了routeros,但仍然显示了错误。 从我的前辈那里得到了这个密码。 我正在尝试收集网络中连接的状态 import routeros_api import json import datetime import sys #make a connection to MikorTik Router connection = routeros_api.RouterOsApiPool('IP', username='name', password='mypassword', pl

我已经在pip中安装了routeros,但仍然显示了错误。 从我的前辈那里得到了这个密码。 我正在尝试收集网络中连接的状态

import routeros_api
import json
import datetime
import sys

#make a connection to MikorTik Router
connection = routeros_api.RouterOsApiPool('IP', username='name', password='mypassword', plaintext_login=True, port=8888)
api = connection.get_api()

#command to retreive data
list_queue = api.get_resource('/queue/tree')
QueueItems = list_queue.get() #get output from Mikrotik command
Uptime = api.get_resource('system/resource')
UptimeItems = Uptime.get() #get output form Mikoritk command
SystemClock = api.get_resource('/system/clock')
SystemClockItems = SystemClock.get()

#list System Clock items
for item in SystemClockItems:
        time = item['time']
        date = item['date']

#list uptime of MikorTik router
for item in UptimeItems:
    range = item["uptime"] #stores uptime from mikroitk in 2d3h30m format
    
CurrentUpTime = range[0] # stores only the 1st digit of Mikortik uptime output whihc corresponds to DAYS

data = {}           #create dictionary to store 
data["time"] = []   #create list in the dictionary to store time key value pair
data["users"] = []  #create lsit in the dictionary to stor users key value pair

data2 = {}           #create dictionary to store new data after mikoritk restarts
data2["time"] = []   #create list in the dictionary to store time key value pair
data2["users"] = []  #create lsit in the dictionary to stor users key value pair

#open output file to compare Uptime of Mirkotik
with open('output.txt','r') as file:
    data = json.load(file)
    for p in data["time"]:
        PreviousUpTime = p['currentuptime']        
#Take data from Queue and store it in file output.txt in json format


data = {}  #create dictionary to store 
data["system"] = []  #create list in the dictionary to store time key value pair
data["users"] = []  #create lsit in the dictionary to stor users key value pair
with open('output.txt','w') as f:  # open file where to dump data
    
    data['system'].append({"currentuptime" : CurrentUpTime}) #add current uptime of Mikrotik
    data['system'].append({"time" : time}) 
    data['system'].append({"date" : date})
    for item in QueueItems:                                  #loop through mikoritk ouptu for each user
        if item["parent"] == "Sharing policy":             #only show user downloads data under this tree
            GigaBytes = int(item["bytes"]) / 1073741824      #convert data to Gigbaytes
            temp_dict = { "name" : item["name"], "Gigabytes" : GigaBytes}
            data['users'].append(temp_dict)
    json.dump(data,f,indent=6)                               #dump data into file opened above in json format 
我得到的输出是

import routeros_api
ModuleNotFoundError:没有名为“routeros\u api”的模块


确保用于安装包的python版本和pip的位置与运行代码所用的python版本相同。@JurgenStrydom pip安装routeros要求已满足:c:\users\username\appdata\local\programs\python\python39\lib\site软件包中的routeros(0.1.1)@JurgenStrydom感谢它帮助我获得了相同的版本但不同的目录