Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install cryptography #2280

Closed
NikolaiT opened this issue Aug 18, 2015 · 4 comments
Closed

Cannot install cryptography #2280

NikolaiT opened this issue Aug 18, 2015 · 4 comments

Comments

@NikolaiT
Copy link

Followed instructions here: http://stackoverflow.com/questions/22073516/failed-to-install-python-cryptography-package-with-pip-and-setup-py

Cannot install. This module is completely useless if not clear installation instructions are given...

Issues:

sudo pip install cryptography --upgrade
Downloading/unpacking cryptography from https://pypi.python.org/packages/source/c/cryptography/cryptography-1.0.tar.gz#md5=3f2608eb94dcc6e616c3cc2e182181b0
  Downloading cryptography-1.0.tar.gz (331kB): 331kB downloaded
  Running setup.py (path:/tmp/pip_build_root/cryptography/setup.py) egg_info for package cryptography

    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*' found under directory 'vectors'
Downloading/unpacking idna>=2.0 (from cryptography)
  Downloading idna-2.0-py2.py3-none-any.whl (61kB): 61kB downloaded
Downloading/unpacking pyasn1>=0.1.8 (from cryptography)
  Downloading pyasn1-0.1.8.tar.gz (75kB): 75kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pyasn1/setup.py) egg_info for package pyasn1

Requirement already up-to-date: six>=1.4.1 in /usr/local/lib/python2.7/dist-packages (from cryptography)
Downloading/unpacking setuptools from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-18.1-py2.py3-none-any.whl#md5=b6c8eae6b3636dd952e71135805ee156 (from cryptography)
  Downloading setuptools-18.1-py2.py3-none-any.whl (461kB): 461kB downloaded
Requirement already up-to-date: enum34 in /usr/local/lib/python2.7/dist-packages (from cryptography)
Downloading/unpacking ipaddress (from cryptography)
  Downloading ipaddress-1.0.14-py27-none-any.whl
Downloading/unpacking cffi>=1.1.0 (from cryptography)
  Downloading cffi-1.1.2.tar.gz (326kB): 326kB downloaded
  Running setup.py (path:/tmp/pip_build_root/cffi/setup.py) egg_info for package cffi

Downloading/unpacking pycparser from https://pypi.python.org/packages/source/p/pycparser/pycparser-2.14.tar.gz#md5=a2bc8d28c923b4fe2b2c3b4b51a4f935 (from cffi>=1.1.0->cryptography)
  Downloading pycparser-2.14.tar.gz (223kB): 223kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pycparser/setup.py) egg_info for package pycparser

    warning: no previously-included files matching 'yacctab.*' found under directory 'tests'
    warning: no previously-included files matching 'lextab.*' found under directory 'tests'
    warning: no previously-included files matching 'yacctab.*' found under directory 'examples'
    warning: no previously-included files matching 'lextab.*' found under directory 'examples'
Installing collected packages: cryptography, idna, pyasn1, setuptools, ipaddress, cffi, pycparser
  Found existing installation: cryptography 0.7.1
    Uninstalling cryptography:
      Successfully uninstalled cryptography
  Running setup.py install for cryptography

    Installed /tmp/pip_build_root/cryptography/.eggs/cffi-1.1.2-py2.7-linux-x86_64.egg
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip_build_root/cryptography/setup.py", line 307, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 272, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 327, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
        return self.resolve()
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ImportError: No module named setuptools_ext
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-X8h31p-record/install-record.txt --single-version-externally-managed --compile:


Installed /tmp/pip_build_root/cryptography/.eggs/cffi-1.1.2-py2.7-linux-x86_64.egg

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/tmp/pip_build_root/cryptography/setup.py", line 307, in <module>

    **keywords_with_side_effects(sys.argv)

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 272, in __init__

    _Distribution.__init__(self,attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 327, in finalize_options

    ep.load()(self, ep.name, value)

  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load

    return self.resolve()

  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve

    module = __import__(self.module_name, fromlist=['__name__'], level=0)

ImportError: No module named setuptools_ext

----------------------------------------
  Rolling back uninstall of cryptography
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-X8h31p-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /home/nikolai/.pip/pip.log
@reaperhulk
Copy link
Member

cffi 1.1 does not appear to have been properly installed (possibly due to a pip issue?). Try pip install -U cffi and then installing cryptography.

@NikolaiT
Copy link
Author

This worked perfectly. Huge thanks for the quick answer. But why is this not mentioned in https://cryptography.io/en/latest/installation/ ? Also: Why is the installation instructions not in the readme if it is not trivial at all? The quickstart doesn't help at all in the README if one cannot install this software so easily. Even PyCrypto can be installed better, makes me want to switch again or to switch the language as a whole because pip/setuptools is a huge pain in the ass (also the whole python3 and python2 thing)... /rant

@znerol
Copy link

znerol commented Oct 7, 2015

I ran into this issue when trying to install buildout based software on Debian Jessie. The following minimal test case was enough to reproduce:

setup.py:

from setuptools import setup

setup(
    name='test',
    version='0.0.1',
    install_requires=[
        'cryptography',
    ],
)

buildout.cfg:

[buildout]
parts = test
develop = .

[test]
recipe = zc.recipe.egg
eggs = test

When trying to bin/buildout i got the following:

Develop: '/tmp/test/.'
Getting distribution for 'zc.recipe.egg>=2.0.0a3'.
Got zc.recipe.egg 2.0.3.
Installing test.
Getting distribution for 'cryptography'.

Installed /tmp/easy_install-8MX6r2/cryptography-1.0.2/.eggs/cffi-1.2.1-py2.7-linux-x86_64.egg
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 2279, in main

  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 389, in run

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 619, in easy_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 668, in install_item

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 851, in install_eggs

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1079, in build_and_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1065, in run_setup

  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 240, in run_setup
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 193, in setup_context
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 164, in save_modules
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 139, in resume
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 152, in save_modules
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 193, in setup_context
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 237, in run_setup
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 267, in run
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 236, in runner
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 46, in _execfile
  File "/tmp/easy_install-8MX6r2/cryptography-1.0.2/setup.py", line 313, in <module>

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 272, in __init__
  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 327, in finalize_options
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2355, in load
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2361, in resolve
ImportError: No module named setuptools_ext
An error occurred when trying to install cryptography 1.0.2. Look above this message for any errors that were output by easy_install.
While:
  Installing test.
  Getting distribution for 'cryptography'.
Error: Couldn't install: cryptography 1.0.2

Turned out that this was caused by an old python-cffi (0.8.6) installed system wide (i.e. via the distributions package manager). apt-get --purge remove python-cffi solved the problem.

@vit1251
Copy link

vit1251 commented Mar 30, 2016

I have pre-installed by apt-get install "python-{package_name}" and pip does not override preinstalled version.

I make apt-get remove each of one and reinstall by pip.

macropin added a commit to panubo/docker-strider-extra that referenced this issue May 5, 2016
William-Yeh added a commit to William-Yeh/docker-ansible that referenced this issue May 9, 2016
William-Yeh added a commit to William-Yeh/docker-ansible that referenced this issue May 10, 2016
Fix:
  1. OS-level packages `libffi-dev` and `libssl-dev`/`openssl-dev` should be installed explicitly since Ansible 2.0.2.0(???).
  2. Python package cffi should be installed explicitly since Ansible 2.0.2.0(???).
  3. add '--fix-missing' for apt.

@see boxcutter/ubuntu#62
@see pyca/cryptography#2280
spang pushed a commit to nylas/sync-engine that referenced this issue Mar 8, 2017
Currently setup.sh keeps failing for me on a Debian 8 VM. Turns out the
error is similar to here pyca/cryptography#2280, which is due to apt
installed of cffi version being less than 1.1.

Command /usr/bin/python -c "import setuptools,
tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize,
'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
'exec'))" install --record /tmp/pip-X8h31p-record/install-record.txt
--single-version-externally-managed --compile failed with error code 1
in /tmp/pip_build_root/cryptography Storing debug log for failure in
/home/nikolai/.pip/pip.log

This PR also fixes #261 #267 #268

setup.sh script now installs libssl-dev #261
added cffi to requirements.txt file which fixes the error in pyca/cryptography#2280 and #268
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants