当我从任何IDLE运行以下代码时:
#!/usr/bin/python3
import json
from napalm import get_network_driver
driver = get_network_driver('ios')
optional_args = {'secret': 'SecretPass'}
SW_3560 = driver('10.0.100.1', 'UserName', 'Password',
optional_args=optional_args)
SW_3560.open()
ios_output = SW_3560.get_facts()
print(json.dumps(ios_output, indent=4))
我得到以下错误输出:
*Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
======= RESTART: C:\Users\daquezada\Dropbox\python\Net_Auto\napalm.py =======
Traceback (most recent call last):
File "C:\Users\daquezada\Dropbox\python\Net_Auto\napalm.py", line 4, in <module>
from napalm import get_network_driver
File "C:\Users\daquezada\Dropbox\python\Net_Auto\napalm.py", line 4, in <module>
from napalm import get_network_driver
ImportError: cannot import name 'get_network_driver'*
但是,如果我在命令行中逐行分别运行每一行,则会得到所需的输出。
请告知。
谢谢。