Cryptography: Install Fails on Ubuntu

Created on 30 Sep 2016  路  6Comments  路  Source: pyca/cryptography

DESCRIPTION

Unable to install cryptography-1.5.2 on Ubuntu 14.04.

STEPS

apt-get install python-pip 
pip install cryptography

EXPECTED RESULTS

The python package would be installed.

ACTUAL RESULTS

$ sudo pip install cryptography
Downloading/unpacking cryptography
  Downloading cryptography-1.5.2.tar.gz (400kB): 400kB 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.1-py2.py3-none-any.whl (54kB): 54kB downloaded
Downloading/unpacking pyasn1>=0.1.8 (from cryptography)
  Downloading pyasn1-0.1.9-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/lib/python2.7/dist-packages (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=11.3 in /usr/local/lib/python2.7/dist-packages (from cryptography)
Downloading/unpacking enum34 (from cryptography)
  Downloading enum34-1.1.6-py2-none-any.whl
Downloading/unpacking ipaddress (from cryptography)
  Downloading ipaddress-1.0.17-py2-none-any.whl
Downloading/unpacking cffi>=1.4.1 (from cryptography)
  Downloading cffi-1.8.3.tar.gz (403kB): 403kB downloaded
  Running setup.py (path:/tmp/pip_build_root/cffi/setup.py) egg_info for package cffi

Downloading/unpacking pycparser (from cffi>=1.4.1->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, enum34, ipaddress, cffi, pycparser
  Running setup.py install for cryptography
    c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip_build_root/cryptography/setup.py", line 334, 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 315, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 361, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 853, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1125, in best_match
        return self.obtain(req, installer)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1137, in obtain
        return installer(requirement)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 429, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 665, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 695, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 876, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1115, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1103, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    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-40arc_-record/install-record.txt --single-version-externally-managed --compile:
    c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory

 #include <Python.h>

                    ^

compilation terminated.

Traceback (most recent call last):

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

  File "/tmp/pip_build_root/cryptography/setup.py", line 334, 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 315, in __init__

    self.fetch_build_eggs(attrs['setup_requires'])

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

    replace_conflicting=True,

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

    dist = best[req.key] = env.best_match(req, ws, installer)

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

    return self.obtain(req, installer)

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

    return installer(requirement)

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

    return cmd.easy_install(req)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 665, in easy_install

    return self.install_item(spec, dist.location, tmpdir, deps)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 695, in install_item

    dists = self.install_eggs(spec, download, tmpdir)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 876, in install_eggs

    return self.build_and_install(setup_script, setup_base)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1115, in build_and_install

    self.run_setup(setup_script, setup_base, args)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1103, in run_setup

    raise DistutilsError("Setup script exited with %s" % (v.args[0],))

distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
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-40arc_-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 /root/.pip/pip.log

Traceback:

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-40arc_-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 707, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python2.7/dist-packages/pip/util.py", line 715, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: 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-40arc_-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography

Most helpful comment

I've solved the problem with usage of the newest Ubuntu 16.04 box. So now, using oficcial installation guide - everything works fine. Sorry for I didn't provide any error information. Mby it works on Ubuntu 14.04, but it does not for sure, if the Ubuntu 14.04 inside vagrant box "ubuntu/trusty64". All you need to reproduce the error, set a provision.sh file to this:

apt-get update
apt-get -y upgrade
apt-get install -y build-essential
apt-get install -y python2.7-dev
apt-get install -y python-pip
apt-get install -y libffi-dev
apt-get install -y libssl-dev
pip install --upgrade pip
pip install cryptography

One more time: the setup above works for "ubuntu/xenial64", but does not for "ubuntu/trusty64" and raises an error about SSL bla-bla crap...

All 6 comments

Please read the installation documentation before filing issues. In this case you're missing the python dev headers (and probably other dev headers as well, but the install halts after the first fatal error).

The installation doc does not help at all, to install it on Ubuntu 14.04. I'm trying set it up inside vagrant with box name "ubuntu/trusty64"...

If the installation documentation is lacking detail then we want to fix that, but you've provided no details of the error or what you tried so we can't provide much guidance. The docs do clearly state to do apt-get install build-essential libssl-dev libffi-dev python-dev on Ubuntu -- does this not work for you?

I've solved the problem with usage of the newest Ubuntu 16.04 box. So now, using oficcial installation guide - everything works fine. Sorry for I didn't provide any error information. Mby it works on Ubuntu 14.04, but it does not for sure, if the Ubuntu 14.04 inside vagrant box "ubuntu/trusty64". All you need to reproduce the error, set a provision.sh file to this:

apt-get update
apt-get -y upgrade
apt-get install -y build-essential
apt-get install -y python2.7-dev
apt-get install -y python-pip
apt-get install -y libffi-dev
apt-get install -y libssl-dev
pip install --upgrade pip
pip install cryptography

One more time: the setup above works for "ubuntu/xenial64", but does not for "ubuntu/trusty64" and raises an error about SSL bla-bla crap...

not work en 14.04 the solution but en 16.04 is fine

I can add to this in that I am dealing with the same issue today.

The error encountered:

SNIP
Processing pycparser-2.19.tar.gz
Writing /tmp/easy_install-uckubY/pycparser-2.19/setup.cfg
Running pycparser-2.19/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uckubY/pycparser-2.19/egg-dist-tmp-VydlK2
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching 'setup.pyc'
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'
zip_safe flag not set; analyzing archive contents...
pycparser.ply.yacc: module references __file__
pycparser.ply.yacc: module MAY be using inspect.getsourcefile
pycparser.ply.yacc: module MAY be using inspect.stack
pycparser.ply.ygen: module references __file__
pycparser.ply.lex: module references __file__
pycparser.ply.lex: module MAY be using inspect.getsourcefile

Installed /tmp/pip_build_root/pynacl/pycparser-2.19-py2.7.egg

warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.travis'
warning: no previously-included files found matching '.travis/install.sh'
warning: no previously-included files found matching '.travis/run.sh'
warning: no previously-included files found matching '.readthedocs.yml'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching 'codecov.yml'
warning: no previously-included files found matching 'tasks.py'
warning: no previously-included files found matching 'Jenkinsfile'
warning: no previously-included files found matching '.jenkins'
warning: no previously-included files found matching '.jenkins/Jenkinsfile-pynacl-wheel-builder'

Downloading/unpacking cryptography>=1.5 (from paramiko->ansible==2.3.2.0)
Downloading cryptography-2.4.2.tar.gz (468kB): 468kB downloaded
Running setup.py (path:/tmp/pip_build_root/cryptography/setup.py) egg_info for package cryptography
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/cryptography/setup.py", line 28, in
"cryptography requires setuptools 18.5 or newer, please upgrade to a "
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_root/cryptography/setup.py", line 28, in

"cryptography requires setuptools 18.5 or newer, please upgrade to a "

RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log

obviously my next step with this Ubuntu 14.04 box is to address the setuptools

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanfoulis picture stefanfoulis  路  7Comments

wexi picture wexi  路  5Comments

ianloic picture ianloic  路  8Comments

webknjaz picture webknjaz  路  7Comments

webknjaz picture webknjaz  路  5Comments