I have Python 2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When I try to run a sample CFFI program:
ffi = FFI()
it says:
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 possible error? Did I miss something during installation? I have installed pip, wheel, pycparser, pytest and cffi.
For python2.x use following command:
python -m pip install cffi
for python3.x
python3 -m pip install cffi
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
I recently had the same issue and none of the above solutions worked for me.
Here is what worked.
sudo apt remove python3-cffi
sudo python3 -m pip install cffi
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.
I had the same problem, following this thread https://github.com/pyca/cryptography/issues/4403, I solved the problem by reinstalling and upgrading with the command:
pip install -U cffi
You have to first remove the following packages:
cryptography
bcrypt
paramiko
Now use the following command to install:
pip -vvv install --upgrade --force-reinstall cffi
Have the same problem. After many attempts adding import cffi solve the issue.
Make sure you have cffi and cryptography installed.
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.
For me there was no way to install cffi on python3.8 because of this:
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
Somehow, the package python3-distutils does not exist in Ubuntu 16.04.
So I ended up installing python3.7 and now I finally could install cffi, fixing the problem mentioned by the TS.
You should install cffi via pip install cffi
to get the latest version. I had to restart my application for it to recognize the cffi installation.
I was getting this error while trying to get the cryptography module to work with Python 3.8 for AWS Lambda.
Adding the cffi*manylinux*.whl files to my Lambda Layer (as suggested here) worked.
The cffi module comes built in for many python distributions, but not on AWS Lambda
For AWS Lambda I was facing the same issue when running on Python3.7. When I downgraded it to Python3.6, this issue was resolved.
I think this packaged might have been present in Python3.6 version and later was removed. Adding this package while making layers for AWS Lambda might resolve the problem for Python3.7.
I encountered this issue when trying to install packages in a local directory using pip install -t . and then running python (2.7). My solution was to remove the -t and not install into a local directory.
it worked after adding " import cffi " in my application.
please refer for more details.
https://buildmedia.readthedocs.org/media/pdf/cffi/latest/cffi.pdf
Thanks to #MPlanchard, for his answer which helped identify the cause
In my case, the issue was related to python3.9, changing to python3.8 it just works well!
After many futile efforts to install the right packages, the right python versions and building the perfect layer, resorting to installing Fabric solved it for me
I got this issue running an Ansible playbook using python 3.9 under Ubuntu-18.04 in WSL2. It was sorted by doing:
sudo apt-get remove -y python3-cffi-backend
sudo apt-get install -y python3-cffi-backend
I am trying to use skimage on mac, and already install the packages with virtualenv, but when I do "from skimage import io", it gave me this error :"ImportError: No module named skimage".
I am wondering if there is anything wrong installation process, but so far I cannot figure it out.
Below is my installation process:
sudo pip install virtualenv
cd /my/project/folder
virtualenv myproject
source myproject/bin/activate
pip install -U scikit-image
Then the result is:
"Successfully installed PyWavelets-0.5.2 cycler-0.10.0 decorator-4.0.11 functools32-3.2.3.post2 matplotlib-2.0.0 networkx-1.11 numpy-1.12.1 olefile-0.44 pillow-4.0.0 python-dateutil-2.6.0 pytz-2017.2 scikit-image-0.13.0 scipy-0.19.0 subprocess32-3.2.7"
It seems that I already have everything, but why import skimage still failed?
Besides, I also tried to used the installation guidance on http://scikit-image.org/download with "pip install -U scikit-image" and "easy_install -U scikit-image", but also failed.
I am on Mac Sierra, with python 2.7. Any suggestion would highly appreciated. Thanks!
conda environment manager fixes this problem.
conda install --yes -c conda-forge scikit-image
I'm using Linux and I couldn't get it working without doing
sudo apt-get install python-skimage
And I got that from the installation page of the docs:
http://scikit-image.org/docs/stable/install.html
I'm not familiar with osx, but maybe try using a package manager like homebrew to install the package like so.
sudo homebrew install python-skimage
I'm actually quite puzzled as to why theres no OSX section in the install section of the docs, but a tiny bit of information in the downloads section.
It's my first time using the build system Semaphore, and I'm having trouble installing scipy while doing my build.
Specifically, it's complaining that BLAS and LAPACK are not installed. Unlike these answers suggests, I can't compile any of the fortran files because Semaphore CI doesn't have them installed on their machines (nor can I install them, because they require root).
What is the proper way of installing scipy in this situation?
(If someone has a suggestion of where to place this question on stackexchange, that would also be appreciated. I'm not sure if this question belongs here.)
It seems travis-ci had a similar issue. Except they resolved it by pre-installing scipy.
Semaphore CI gives you a passwordless sudo in your build environment, so you can use commands suggested in the official documentation in your build setup like:
sudo apt-get update
sudo apt-get install python python-dev libatlas-base-dev gcc gfortran g++
sudo pip install scipy
I'm trying to upgrade Scipy from 0.9.0 to 0.12.0. I use the command:
sudo pip install --upgrade scipy
and I get all sorts of errors which can be seen in the pip.log file here and I'm unfortunately not python-savvy enough to understand what's wrong. Any help will be appreciated.
The error messages all state the same: You lack BLAS (Basic Linear Algebra Subroutines) on your system, or scipy cannot find it. When installing packages from source in ubuntu, as you are effectively trying to do with pip, one of the easiest ways to make sure dependencies are in place is by the command
$ sudo apt-get build-dep python-scipy
which will install all packages needed to build the package python-scipy. You may in some cases run into the problem that the version of the source package you are trying to install have different dependencies than the version included with ubuntu, but in your case, I think chances are good that the above command will be sufficient to fetch BLAS for you, headers included.
I had the same problem upgrading from scipy 0.9 to 0.13.3, and I solved it using the following answer and installing:
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
sudo apt-get install gfortran
Make sure libatlas-base-dev and libatlas-sse2-dev are installed, it seems like it can't find your atlas library. Also, see this question:
Does Python SciPy need BLAS?
I found Adam Klein's instructions for setting up scipy (and friends) in a virtual environment very useful.
One problem I ran into (which was probably my own fault): After all was said and done, I found importing scipy still loaded version 0.9.0, not 0.12.0. The problem was that my sys.path was finding the old system version before the new version.
The fix was to make
/path/to/.virtualenvs/arthur/local/lib/python2.7/site-packages
appear before
/usr/lib/python2.7/dist-packages
in sys.path. If you have virtualenvwrapper installed, then
you can add the path using
add2virtualenv /path/to/.virtualenvs/arthur/lib/python2.7/site-packages
I installed paramiko in my Ubuntu box "sudo apt-get install python-paramkio".
But when import the paramiko module i am getting error.
ImportError:No Module named paramiko
When i list the python modules using help('modules'). i couldn't find paramiko listed.
To use python libraries, you must have development version of python like python2.6-dev, which can be installed using sudo apt-get install python2.6-dev.
Then you may install any additional development libraries that you want in your code to run.
Whatever you install using sudo apt-get install python-paramkio or python setup.py install will then be available to you.