No 'get_network_driver' in Python3 Napalm on Ubuntu Network Automation Container

690 views Asked by At

I'm currently working on Network Automation Container in GNS3. While I'm trying to use napalm lib, I'm getting either or these two errors:

  • "ImportError: cannot import name 'get_network_driver' from partially initialized module 'napalm' (most likely due to a circular import ) (/root/napalm.py)"

  • "AttributeError: partially initialized module 'napalm' has no attribute 'get_network_driver' (most likely due to a circular import)"

I checked Python version on this machine and it's 3.8.3 so the napalm is supported here. Does anyone know what can cause this error?

2

There are 2 answers

0
Mert Kulac On
There are 2 probable issues:
1. The nano files you created and saved in the appliance
2. Python - Netmiko - Napalm versions compatibility

Network Automation Appliance (NAA) comes preinstalled with Python 2.7 & 3.8 + 
Netmiko 3.0 + Napalm 2.5.0.

You can see this with >>> pip freeze

Solution:
Use a fresh Network Automation Appliance (NAA) in your GNS3 topology.
Re-install Napalm in NAA with >>> pip install napalm
(This will auto-install Napalm's compatible version of Netmiko)

Check the version of Napalm and Netmiko installed with >>> pip freeze

napalm==2.5.0
netmiko==2.4.2
paramiko==2.7.1
0
ubaumann On

Tl;dr: Don't name your file napalm.py

Your file is called napalm.py and the library is also called napalm. When you do a from napalm import get_network_driver, Python looks in your file napalm.py for get_network_driver. So the best thing would be to rename your file.