Cryptography: Cryptography installation is failing

Created on 1 Aug 2017  路  14Comments  路  Source: pyca/cryptography

Hi,

I am running Python version 2.6.0 on a CentOS server.

Linux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Sun Nov 10 22:19:54 EST 2013

I am failing to install the crypto package.

# sudo pip install cryptography-2.0.2.tar.gz 
Processing ./cryptography-2.0.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): idna>=2.1 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): asn1crypto>=0.21.0 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.7 in /usr/lib64/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): ordereddict in /usr/lib/python2.6/site-packages (from enum34->cryptography==2.0.2)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/lib/python2.6/site-packages (from cffi>=1.7->cryptography==2.0.2)
Installing collected packages: cryptography
  Running setup.py install for cryptography
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-bZlo9d-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-goQYzU-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-bZlo9d-build/setup.py", line 312, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib64/python2.6/distutils/core.py", line 113, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python2.6/site-packages/setuptools/dist.py", line 225, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib64/python2.6/distutils/dist.py", line 270, in __init__
        self.finalize_options()
      File "/usr/lib/python2.6/site-packages/setuptools/dist.py", line 258, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 161, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 48, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 24, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 106, in <module>
        extra_link_args=extra_link_args(compiler_type()),
      File "/tmp/pip-bZlo9d-build/src/_cffi_src/utils.py", line 49, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip-bZlo9d-build/src/_cffi_src/utils.py", line 58, in build_ffi
        ffi.cdef(cdef_source)
      File "/usr/lib64/python2.6/site-packages/cffi/api.py", line 105, in cdef
        self._cdef(csource, override=override, packed=packed)
      File "/usr/lib64/python2.6/site-packages/cffi/api.py", line 119, in _cdef
        self._parser.parse(csource, override=override, **options)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 299, in parse
        self._internal_parse(csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 304, in _internal_parse
        ast, macros, csource = self._parse(csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 262, in _parse
        self.convert_pycparser_error(e, csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 291, in convert_pycparser_error
        raise api.CDefError(msg)
    cffi.api.CDefError: cannot parse "typedef int __dotdotdot__  time_t;"
    :24:28: before: time_t

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-bZlo9d-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-goQYzU-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-bZlo9d-build

Any pointers on what could be the issue?

Most helpful comment

Also just to add I resolved the same issue by upgrading cffi to version 1.10.0. Again if you cannot use the above solutions I hope this will help

All 14 comments

Please upgrade your pip to the latest version and try the install again. If you still get the same error we'll proceed from there :smile:

@reaperhulk , just did. pip is now on 9.0.1. The issue exists.
Thanks

Okay, what version of CentOS and can you supply the output of pip install -vvv cryptography (a verbose install). That will be a lot of output so you might want to put it in a gist or something.

@reaperhulk : The device doesn't have internet connectivity. Did a local install:

[root@user]#  pip install -vvv cryptography-2.0.2.tar.gz 
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Ignoring indexes: https://pypi.python.org/simple
Processing ./cryptography-2.0.2.tar.gz
  Running setup.py (path:/tmp/pip-KTSi7X-build/setup.py) egg_info for package from file:///home/user/cryptography-2.0.2.tar.gz
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/cryptography.egg-info
    writing requirements to pip-egg-info/cryptography.egg-info/requires.txt
    writing pip-egg-info/cryptography.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/cryptography.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/cryptography.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/cryptography.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    reading manifest file 'pip-egg-info/cryptography.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*' found under directory 'vectors'
    writing manifest file 'pip-egg-info/cryptography.egg-info/SOURCES.txt'
  Source in /tmp/pip-KTSi7X-build has version 2.0.2, which satisfies requirement cryptography==2.0.2 from file:///home/user/cryptography-2.0.2.tar.gz
Requirement already satisfied: idna>=2.1 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: enum34 in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: ipaddress in /usr/lib/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: cffi>=1.7 in /usr/lib64/python2.6/site-packages (from cryptography==2.0.2)
Requirement already satisfied: ordereddict in /usr/lib/python2.6/site-packages (from enum34->cryptography==2.0.2)
Requirement already satisfied: pycparser in /usr/lib/python2.6/site-packages (from cffi>=1.7->cryptography==2.0.2)
Installing collected packages: cryptography
  Running setup.py install for cryptography ...     Running command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-KTSi7X-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-prHztt-record/install-record.txt --single-version-externally-managed --compile
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-KTSi7X-build/setup.py", line 312, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib64/python2.6/distutils/core.py", line 113, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python2.6/site-packages/setuptools/dist.py", line 225, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib64/python2.6/distutils/dist.py", line 270, in __init__
        self.finalize_options()
      File "/usr/lib/python2.6/site-packages/setuptools/dist.py", line 258, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 161, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 48, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/usr/lib64/python2.6/site-packages/cffi/setuptools_ext.py", line 24, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 106, in <module>
        extra_link_args=extra_link_args(compiler_type()),
      File "/tmp/pip-KTSi7X-build/src/_cffi_src/utils.py", line 49, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip-KTSi7X-build/src/_cffi_src/utils.py", line 58, in build_ffi
        ffi.cdef(cdef_source)
      File "/usr/lib64/python2.6/site-packages/cffi/api.py", line 105, in cdef
        self._cdef(csource, override=override, packed=packed)
      File "/usr/lib64/python2.6/site-packages/cffi/api.py", line 119, in _cdef
        self._parser.parse(csource, override=override, **options)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 299, in parse
        self._internal_parse(csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 304, in _internal_parse
        ast, macros, csource = self._parse(csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 262, in _parse
        self.convert_pycparser_error(e, csource)
      File "/usr/lib64/python2.6/site-packages/cffi/cparser.py", line 291, in convert_pycparser_error
        raise api.CDefError(msg)
    cffi.api.CDefError: cannot parse "typedef int __dotdotdot__  time_t;"
    :24:28: before: time_t
error
Cleaning up...
  Removing source in /tmp/pip-KTSi7X-build
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-KTSi7X-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-prHztt-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-KTSi7X-build/
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/lib/python2.6/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/lib/python2.6/site-packages/pip/req/req_install.py", line 878, in install
    spinner=spinner,
  File "/usr/lib/python2.6/site-packages/pip/utils/__init__.py", line 707, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-KTSi7X-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-prHztt-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-KTSi7X-build/
[root@user]# 

Version: Red Hat Enterprise Linux Server release 6.5 (Santiago)

What version of cffi do you have installed?

@alex cffi==1.7.0

Can you try installing using the manylinux1 wheel from pypi?

RHEL 6.5 is pretty out of date, even within the RHEL 6 world, so it's likely this is caused by some out of date system software.

@alex I did try that before, however I got this:

# pip install cryptography-2.0.2-cp26-cp26m-manylinux1_x86_64.whl 
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
cryptography-2.0.2-cp26-cp26m-manylinux1_x86_64.whl is not a supported wheel on this platform.

Chances are you need the cp26-cp26mu wheel and not the cp26-cp26m

@reaperhulk That worked! Thank you for all the help :)

Hi! I had the same problem and solved by upgrading pip with pip install --upgrade pip before installing cryptography. Maybe if the solution above doesn't work this could help :)

Also just to add I resolved the same issue by upgrading cffi to version 1.10.0. Again if you cannot use the above solutions I hope this will help

andrewyatz
how do you upgrade cffi to version 1.10.0?

@gameguyr for you (unless you moved past this and got it working), or anyone after:

pip install --upgrade cffi

or for the specific version

pip install cffi==1.10.0
Was this page helpful?
0 / 5 - 0 ratings

Related issues

TrollNation picture TrollNation  路  20Comments

reaperhulk picture reaperhulk  路  22Comments

reaperhulk picture reaperhulk  路  42Comments

alex picture alex  路  28Comments

anlutro picture anlutro  路  23Comments