I just installed/upgraded the following packages on my system (Mac OSX 10.7.5, using python 2.7.11).
package | build
---------------------------|-----------------
enum34-1.1.2 | py27_0 55 KB
idna-2.0 | py27_0 123 KB
ipaddress-1.0.14 | py27_0 27 KB
pyasn1-0.1.9 | py27_0 54 KB
pycparser-2.14 | py27_0 147 KB
cffi-1.2.1 | py27_0 167 KB
cryptography-1.0.2 | py27_0 370 KB
pyopenssl-0.14 | py27_0 122 KB
ndg-httpsclient-0.3.3 | py27_0 30 KB
------------------------------------------------------------
Total: 1.1 MB
Afterwards, I get the following error when trying to call pip or anaconda:
'CompiledFFI' object has no attribute 'def_extern'
What's going on and how do I fix this?
Here's the full error message:
$ conda
Traceback (most recent call last):
File "/Users/User/miniconda/bin/conda", line 5, in <module>
sys.exit(main())
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 118, in main
from conda.cli import main_search
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/cli/main_search.py", line 12, in <module>
from conda.misc import make_icon_url
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/misc.py", line 19, in <module>
from conda.api import get_index
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/api.py", line 10, in <module>
from conda.fetch import fetch_index
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/fetch.py", line 24, in <module>
from conda.connection import CondaSession, unparse_url, RETRIES
File "/Users/User/miniconda/lib/python2.7/site-packages/conda/connection.py", line 24, in <module>
import requests
File "/Users/User/miniconda/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Users/User/miniconda/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 54, in <module>
import OpenSSL.SSL
File "/Users/User/miniconda/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/Users/User/miniconda/lib/python2.7/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/Users/User/miniconda/lib/python2.7/site-packages/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/Users/User/miniconda/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 68, in <module>
error=-1)
File "/Users/User/miniconda/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 57, in wrapper
ffi.def_extern(name=name, **kwargs)(func)
AttributeError: 'CompiledFFI' object has no attribute 'def_extern'
I had this error too, but I've resolved it by upgrading cffi like so:
pip install --upgrade cffi
Upgrading cffi did not solve it for me; I did:
sudo apt-get purge --auto-remove python-cryptography
and then reinstalled cryptography.
I solve the problem with this solution
easy_install -U cffi
https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1512792/comments/11
I am answering the question this late, as all of the above answers didn't work me.
Cause: The probable cause was cffi
package version i.e. 1.2.1 (in my case 1.3.0).
Solution: Upgrade cffi
package. But it isn't that simple as most probably it'd have broken your pip
as well.
First uninstall pip (for CentOS 7):
yum remove -y python-pip
Once removed, now delete the cffi package manually:
To get the exact path:
$ python
>>> import cffi
>>> cffi.__path__
['/usr/lib64/python2.7/site-packages/cffi']
Now go to the directory: cd /usr/lib64/python2.7/site-packages - to check what cffi files and folders are there:
ls | grep cffi
cffi
cffi-1.3.0-py2.7.egg-info
_cffi_backend.so
Remove the cffi relevant files and folders:
rm -rf cffi cffi-1.3.0-py2.7.egg-info/ _cffi_backend.so
Re-installing pip:
yum install -y python-pip
Installing the latest cffi package:
pip install cffi==1.8.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With