Import error when using netmiko with django : No module named '_cffi_backend'

╄→尐↘猪︶ㄣ 提交于 2019-12-20 07:46:30

问题


Netmiko works fine when I execute below script file (test.py) from the linux cli

#!/var/www/html/devopsenv/bin/python

from netmiko import ConnectHandler import getpass

cisco_asr = { 'device_type': 'cisco_xr', 'ip': 'my ip', 'username': 'user', '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)

However when I try to use the same script from a django view by importing as below, I get the import error.

from netmiko import ConnectHandler

import error picture

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']

回答1:


found the problem works perfectly with python 3.5 seems there is a bug on python 3.6 that causes it to throw the cffi-backend error when used with netmiko



来源:https://stackoverflow.com/questions/54195948/import-error-when-using-netmiko-with-django-no-module-named-cffi-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!