cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6574
Views
18
Helpful
4
Replies

Python netmiko error

minhtetsan192
Level 1
Level 1

Dear Sir,

 

I'm a beginner at Network automation. Please kindly help with my issue.

===========================================

from netmiko import ConnectHandler

MHS_SWITCHES = {
'device_type' : 'cisco_ios',
'ip': '192.168.32.100',
'username' : 'admin',
'password' : 'cisco',
'secret': 'secret'
}

net_connect = ConnectHandler(**MHS_SWITCHES)
onput = net_connect.send_command('show ip int brief')
print(onput)

=============================================

 

This is my simple python file with netmiko. But, if I run this script, I always get an error. Please check below.

=============

root@davidsam-virtual-machine:/etc/python3.10# python3 netmiko.py
Traceback (most recent call last):
File "/etc/python3.10/netmiko.py", line 1, in <module>
from netmiko import ConnectHandler
File "/etc/python3.10/netmiko.py", line 1, in <module>
from netmiko import ConnectHandler
ImportError: cannot import name 'ConnectHandler' from partially initialized module 'netmiko' (most likely due to a circular import) (/etc/python3.10/netmiko.py)

============================

 

pip list | grep netmiko
netmiko 4.1.0

=================

 

python3 --version
Python 3.10.4

=====================

I need your support. Thanks!!!

 

 

2 Accepted Solutions

Accepted Solutions

Hi

  It seems to me some conflict. You created a file called netmiko.py, rith?   Try to use a different name.  As per the logs, it seems that it is trying use your file as part of the Netmiko library and is failing.

 

ImportError: cannot import name 'ConnectHandler' from partially initialized module 'netmiko' (most likely due to a circular import)

 

View solution in original post

#Mat
Level 6
Level 6

Hello minhtetsan192 ! Change your app netmiko.py to, for example, main.py and try again.

Regards,

MO.

 

 

.

View solution in original post

4 Replies 4

Hi

  It seems to me some conflict. You created a file called netmiko.py, rith?   Try to use a different name.  As per the logs, it seems that it is trying use your file as part of the Netmiko library and is failing.

 

ImportError: cannot import name 'ConnectHandler' from partially initialized module 'netmiko' (most likely due to a circular import)

 

Thank you so much, sir. Now my issue was soloved.

 

Best Warm Regards,

Min Htet San

#Mat
Level 6
Level 6

Hello minhtetsan192 ! Change your app netmiko.py to, for example, main.py and try again.

Regards,

MO.

 

 

.

Thank you so much, sir. Now my issue was solved.

 

Best Warm Regards,

Min Htet San