I'm writing a small script in Python, as a part of my networking class homework.
I have to run this script in cmd.exe, but it keeps giving me error ModuleNotFoundError: No module named 'paramiko'
. It only works in IDLE, and only in 3.10 version.
File "C:\Users\drafthard\Documents\routerconfigscript4.py", line 1, in <module>
import paramiko
ModuleNotFoundError: No module named 'paramiko'
I've tried reinstalling paramiko, reinstalling pip, clearing pip cache and installing paramiko again, showing path to paramiko files but nothing works.
Any idea how to solve this problem?
import paramiko
import time
user = 'user1'
pass1 = '12345'
port = 22
cisco = ['172.16.0.1', '172.16.0.2']
for host in cisco:
print('------Start---'+host+'------')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=host, username=user, password=pass1, port=port)
chan = client.invoke_shell()
time.sleep(2)
chan.send('terminal length 0\n')
time.sleep(1)
chan.send('show run\n')
time.sleep(1)
result = chan.recv(5000).decode('utf-8')
filename= str(host)+'.txt'
file=open(filename, 'w')
file.write(result)
file.close()
print(result)
time.sleep(2)
client.close()
print('------End-----'+host+'------')