当我从linux cli执行以下脚本文件(test.py)时,Netmiko可以正常工作
#!/ var / www / html / devopsenv / bin / python
从netmiko导入ConnectHandler导入getpass
cisco_asr = { 'device_type':'cisco_xr', 'ip':'我的ip', '用户名':'用户', 'password':'pass', 'verbose':True}
net_connect = ConnectHandler(**cisco_asr) config_commands = [ 'int BE222.2481', 'vrf devops_test', 'ip add 10.1.1.1/30'] output = net_connect.send_config_set(config_commands) #net_connect.commit() print(output)
但是,当我尝试通过如下所示的方式从django视图中使用相同的脚本时,出现导入错误。
from netmiko import ConnectHandler
ImportError at /
No module named '_cffi_backend'
Request Method: GET
Request URL: http://W.X.Y.Z/
Django Version: 2.1.4
Exception Type: ImportError
Exception Value:
No module named '_cffi_backend'
Exception Location: /var/www/html/devopsenv/lib/python3.6/site-packages/bcrypt/__init__.py in <module>, line 25
Python Executable:
Python Version: 3.5.6
Python Path:
['/var/www/html/devops',
'/var/www/html/devopsenv/lib/python3.6/site-packages',
'/lib64/python35.zip',
'/lib64/python3.5',
'/lib64/python3.5/plat-linux',
'/lib64/python3.5/lib-dynload',
'/lib64/python3.5/site-packages',
'/lib/python3.5/site-packages']
答案 0 :(得分:0)
发现问题 与python 3.5完美搭配 似乎在python 3.6上存在一个错误,导致与netmiko一起使用时会引发cffi-backend错误