Cryptography install error because of pycparser then init bench fails

Installing collected packages: pyasn1, idna, six, enum34, ipaddress, pycparser, cffi, cryptography, paramiko, MarkupSafe, jinja2, PyYAML, pycrypto, ansible
  Running setup.py install for pycparser ... done
  Running setup.py install for cryptography ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-o3iDZX/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-J7hl_J-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-o3iDZX/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 "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 318, 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 376, in finalize_options
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 181, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 48, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 24, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 81, in <module>
        extra_link_args=extra_link_args(compiler_type()),
      File "/tmp/pip-build-o3iDZX/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip-build-o3iDZX/cryptography/src/_cffi_src/utils.py", line 70, in build_ffi
        ffi.cdef(cdef_source)
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 105, in cdef
        self._cdef(csource, override=override, packed=packed)
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 119, in _cdef
        self._parser.parse(csource, override=override, **options)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 299, in parse
        self._internal_parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 304, in _internal_parse
        ast, macros, csource = self._parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 260, in _parse
        ast = _get_parser().parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 40, in _get_parser
        _parser_cache = pycparser.CParser()
      File "/usr/local/lib/python2.7/dist-packages/pycparser/c_parser.py", line 87, in __init__
        outputdir=taboutputdir)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/c_lexer.py", line 66, in build
        self.lexer = lex.lex(object=self, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 911, in lex
        lexobj.readtab(lextab, ldict)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 233, in readtab
        titem.append((re.compile(pat, lextab._lexreflags | re.VERBOSE), _names_to_funcs(func_name, fdict)))
      File "/usr/lib/python2.7/re.py", line 194, in compile
        return _compile(pattern, flags)
      File "/usr/lib/python2.7/re.py", line 249, in _compile
        p = sre_compile.compile(pattern, flags)
      File "/usr/lib/python2.7/sre_compile.py", line 583, in compile
        "sorry, but this version only supports 100 named groups"
    AssertionError: sorry, but this version only supports 100 named groups
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-o3iDZX/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-J7hl_J-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-o3iDZX/cryptography/
Traceback (most recent call last):
  File "install.py", line 351, in <module>
    install_bench(args)
  File "install.py", line 64, in install_bench
    'pip': "sudo pip install 'ansible==2.0.2.0'"
  File "install.py", line 219, in run_os_command
    returncode = subprocess.check_call(command, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'sudo pip install 'ansible==2.0.2.0'' returned non-zero exit status 1

I got this error while doing sudo python install.py --develop.
I found that this is an error with pycparser as stated in this SO post:

Doing sudo pip install git+https://github.com/eliben/pycparser@release_v2.14 before install worked for me.

But then I got this error:

TASK [init bench] **************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["bench", "init", "/home/vagrant/frappe-bench", "--frappe-branch", "develop"], "delta": "0:01:52.455432", "end": "2016-10-18 17:20:33.371371", "failed": true, "rc": 1, "start": "2016-10-18 17:18:40.915939", "stderr": "INFO:bench.app:getting app frappe\nKlone nach 'frappe' ...\nINFO:bench.app:installing frappe\nCommand \"/home/vagrant/frappe-bench/env/bin/python -u -c \"import setuptools, tokenize;__file__='/tmp/pip-build-OyxRyD/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))\" install --record /tmp/pip-pa4fN7-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/vagrant/frappe-bench/env/include/site/python2.7/cryptography\" failed with error code 1 in /tmp/pip-build-OyxRyD/cryptography/\nTraceback (most recent call last):\n  File \"/usr/local/bin/bench\", line 11, in <module>\n    load_entry_point('bench', 'console_scripts', 'bench')()\n  File \"/home/vagrant/.bench/bench/cli.py\", line 40, in cli\n    bench_command()\n  File \"/usr/local/lib/python2.7/dist-packages/click/core.py\", line 716, in __call__\n    return self.main(*args, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/click/core.py\", line 696, in main\n    rv = self.invoke(ctx)\n  File \"/usr/local/lib/python2.7/dist-packages/click/core.py\", line 1060, in invoke\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\n  File \"/usr/local/lib/python2.7/dist-packages/click/core.py\", line 889, in invoke\n    return ctx.invoke(self.callback, **ctx.params)\n  File \"/usr/local/lib/python2.7/dist-packages/click/core.py\", line 534, in invoke\n    return callback(*args, **kwargs)\n  File \"/home/vagrant/.bench/bench/commands/make.py\", line 19, in init\n    verbose=verbose, clone_from=clone_from)\n  File \"/home/vagrant/.bench/bench/utils.py\", line 56, in init\n    get_app(frappe_path, branch=frappe_branch, bench_path=path, build_asset_files=False, verbose=verbose)\n  File \"/home/vagrant/.bench/bench/app.py\", line 73, in get_app\n    install_app(app=app_name, bench_path=bench_path, verbose=verbose)\n  File \"/home/vagrant/.bench/bench/app.py\", line 103, in install_app\n    find_links=find_links))\n  File \"/home/vagrant/.bench/bench/utils.py\", line 127, in exec_cmd\n    raise CommandFailedError(cmd)\nbench.utils.CommandFailedError: /home/vagrant/frappe-bench/env/bin/pip install -q  -e /home/vagrant/frappe-bench/apps/frappe", "stdout": "Already using interpreter /usr/bin/python\ninstalling frappe", "stdout_lines": ["Already using interpreter /usr/bin/python", "installing frappe"], "warnings": []}
        to retry, use: --limit @develop/install.retry

PLAY RECAP *********************************************************************
localhost                  : ok=31   changed=20   unreachable=0    failed=1   

Traceback (most recent call last):
  File "install.py", line 351, in <module>
    install_bench(args)
  File "install.py", line 108, in install_bench
    run_playbook('develop/install.yml', sudo=True, extra_vars=extra_vars)
  File "install.py", line 301, in run_playbook
    success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks'))
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'develop/install.yml', '-e', '@/tmp/extra_vars.json', '--become', '--become-user=vagrant']' returned non-zero exit status 2

Seems like this is also originating from cryptography/pycparser. This happened on Ubuntu 14.04 and 16.04.
What to do now?

pycparser was updated and I’m now able to finish the install process.

https://github.com/pyca/cryptography/issues/3187#issuecomment-254582101