- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:04 AM
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!!!
Solved! Go to Solution.
- Labels:
-
Other Networking Topics
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:14 AM
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)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:15 AM
Hello minhtetsan192 ! Change your app netmiko.py to, for example, main.py and try again.
Regards,
MO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:14 AM
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 05:16 AM
Thank you so much, sir. Now my issue was soloved.
Best Warm Regards,
Min Htet San
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 06:59 AM
Thanks, I just made this exact error as well!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:15 AM
Hello minhtetsan192 ! Change your app netmiko.py to, for example, main.py and try again.
Regards,
MO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 05:16 AM
Thank you so much, sir. Now my issue was solved.
Best Warm Regards,
Min Htet San
