No module named _cffi_backend

戏子无情 提交于 2019-12-21 03:35:24

问题


I have python2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When i try to run a sample CFFI program it says :

ffi = FFI()

File "/usr/lib/python2.6/site-packages/cffi/api.py", line 56, in init

import _cffi_backend as backend

ImportError: No module named _cffi_backend

what could be the posiible error. Did i miss something during install. i have installed pip, wheel, pycparser, pytest, cffi....


回答1:


For python2.x use following command:

python -m pip install cffi

for python3.x

python3 -m pip install cffi



回答2:


I needed to uninstall and install it again:

sudo pip uninstall cryptography

sudo pip uninstall paramiko

then install pagamiko again

sudo pip install paramiko

and it start to work for me




回答3:


Have the same problem. After many attempts adding import cffi solve the issue.

Make sure you have cffi and cryptography installed.




回答4:


Did you compile Python from source, and if so, did it give you any errors during the configure/make/make install phase? Compiling Python from source can be a real beast on older Red Hat systems, so if you installed that way, I'd suggest combing through the configure and make output to be sure that no modules were left out.

In order to get pip install cffi to succeed with no errors, I had to install gcc and libffi-devel from the EL5 repos. From there, I was able to instantiate an FFI instance with no problems:

>>> from cffi import FFI
>>> ffi = FFI()
>>>

Here's the output of pip freeze, for reference:

[root@machine ~]# pip freeze
argparse==1.2.1
autobahn==0.8.10
cffi==1.5.2
characteristic==14.3.0
pika==0.9.13
pyasn1==0.1.7
pyasn1-modules==0.0.8
pycparser==2.14
pycrypto==2.6.1
pyOpenSSL==0.12
pysnmp==4.2.5
requests==2.7.0
service-identity==14.0.0
six==1.7.3
Twisted==14.0.0
version-utils==0.2.2
wheel==0.24.0
zope.interface==4.1.1

If you've got the same or better versions of the relevant packages installed, I'd try a pip -vvv install --upgrade --force-reinstall cffi, just to see if there are perhaps errors that pip was masking, and go from there.




回答5:


You could look at the code L56 in /usr/lib/python2.6/site-packages/cffi/api.py

It needs the _cffi_backend.so in your pythonpath. You could install the python-cffi for it. But not sure whether it is in your RPM repo, especially you are using RHEL-5. Here is an RPM for CENTOS http://cbs.centos.org/koji/rpminfo?rpmID=20613 Hope it helps. I am still searching the source code for building the _cffi_backend.so.



来源:https://stackoverflow.com/questions/34370962/no-module-named-cffi-backend

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