1

Steps I've tried so far:

  1. create the virtual environment.

    python3.4 -m venv [venv_name_here]

  2. enter the virtual environment.

    cd [venv_name_here]

  3. activate the virtual environment.

    source bin/activate

  4. install setuptools.

    pip install --upgrade setuptools

  5. install pyparser.

    pip install --upgrade pyparser

Output:

Downloading/unpacking pyparser
  Downloading pyparser-1.0.tar.gz
  Running setup.py (path:[path-to-venv]/build/pyparser/setup.py) egg_info for package pyparser
Downloading/unpacking parse==1.6.5 (from pyparser)
  Downloading parse-1.6.5.tar.gz
  Running setup.py (path:[path-to-venv]/build/parse/setup.py) egg_info for package parse
Installing collected packages: pyparser, parse
  Running setup.py install for pyparser
  Could not find .egg-info directory in install record for pyparser
  Running setup.py install for parse
  Could not find .egg-info directory in install record for parse==1.6.5 (from pyparser)
Successfully installed pyparser parse
Cleaning up..
  1. install cffi.

    pip install --upgrade cffi

Output:

Downloading/unpacking cffi
  Downloading cffi-1.11.5.tar.gz (438kB): 438kB downloaded
  Running setup.py (path:[path-to-venv]/build/cffi/setup.py) egg_info for package cffi
Downloading/unpacking pycparser (from cffi)
  Downloading pycparser-2.18.tar.gz (245kB): 245kB downloaded
  Running setup.py (path:[path-to-venv]/build/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: cffi, pycparser
  Running setup.py install for cffi
    building '_cffi_backend' extension
    gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/local/lib/libffi-3.1/include -I[path-to-venv]/include -I/usr/local/include/python3.4m -c c/_cffi_backend.c -o build/temp.linux-i686-3.4/c/_cffi_backend.o
    gcc -pthread -shared build/temp.linux-i686-3.4/c/_cffi_backend.o -L$(libdir) -lffi -o build/lib.linux-i686-3.4/_cffi_backend.cpython-34m.so
  Could not find .egg-info directory in install record for cffi
  Running setup.py install for 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'
    Build the lexing/parsing tables
  Could not find .egg-info directory in install record for pycparser (from cffi)
Successfully installed cffi pycparser
Cleaning up...
  1. install cryptography.

    pip install --upgrade cryptography

Output:

Downloading/unpacking cryptography
  Downloading cryptography-2.2.2.tar.gz (443kB): 443kB downloaded
  Running setup.py (path:[path-to-venv]/build/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.1 (from cryptography)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB): 56kB downloaded
Downloading/unpacking asn1crypto>=0.21.0 (from cryptography)
  Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB): 101kB downloaded
Downloading/unpacking six>=1.4.1 (from cryptography)
  Downloading six-1.11.0-py2.py3-none-any.whl
Installing collected packages: cryptography, idna, asn1crypto, six
  Running setup.py install for cryptography
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "[path-to-venv]/build/cryptography/setup.py", line 319, in <module>
        **keywords_with_side_effects(sys.argv)
      File "[path-to-venv]/lib/python3.4/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "[path-to-venv]/lib/python3.4/site-packages/setuptools/dist.py", line 363, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/local/lib/python3.4/distutils/dist.py", line 280, in __init__
        self.finalize_options()
      File "[path-to-venv]/lib/python3.4/site-packages/setuptools/dist.py", line 519, in finalize_options
        ep.load()(self, ep.name, value)
      File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 204, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 25, 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 "[path-to-venv]/build/cryptography/src/_cffi_src/utils.py", line 49, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "[path-to-venv]/build/cryptography/src/_cffi_src/utils.py", line 57, in build_ffi
        ffi = FFI()
      File "[path-to-venv]/lib/python3.4/site-packages/cffi/api.py", line 46, in __init__
        import _cffi_backend as backend
    ImportError: [path-to-venv]/lib/python3.4/site-packages/_cffi_backend.cpython-34m.so: undefined symbol: __syscall_error
    Complete output from command [path-to-venv]/bin/python3.4 -c "import setuptools, tokenize;__file__='[path-to-venv]/build/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pm4i20dg-record/install-record.txt --single-version-externally-managed --compile --install-headers [path-to-venv]/include/site/python3.4:
    Traceback (most recent call last):

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

  File "[path-to-venv]/build/cryptography/setup.py", line 319, in <module>
    **keywords_with_side_effects(sys.argv)

  File "[path-to-venv]/lib/python3.4/site-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)

  File "/usr/local/lib/python3.4/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)

  File "[path-to-venv]/lib/python3.4/site-packages/setuptools/dist.py", line 363, in __init__
    _Distribution.__init__(self, attrs)

  File "/usr/local/lib/python3.4/distutils/dist.py", line 280, in __init__
    self.finalize_options()

  File "[path-to-venv]/lib/python3.4/site-packages/setuptools/dist.py", line 519, in finalize_options
    ep.load()(self, ep.name, value)

  File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 204, in cffi_modules
    add_cffi_module(dist, cffi_module)

  File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
    execfile(build_file_name, mod_vars)

  File "[path-to-venv]/lib/python3.4/site-packages/cffi/setuptools_ext.py", line 25, 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 "[path-to-venv]/build/cryptography/src/_cffi_src/utils.py", line 49, in build_ffi_for_binding
    extra_link_args=extra_link_args,

  File "[path-to-venv]/build/cryptography/src/_cffi_src/utils.py", line 57, in build_ffi
    ffi = FFI()

  File "[path-to-venv]/lib/python3.4/site-packages/cffi/api.py", line 46, in __init__
    import _cffi_backend as backend

ImportError: [path-to-venv]/lib/python3.4/site-packages/_cffi_backend.cpython-34m.so: undefined symbol: __syscall_error

----------------------------------------
Cleaning up...
Command [path-to-venv]/bin/python3.4 -c "import setuptools, tokenize;__file__='[path-to-venv]/build/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pm4i20dg-record/install-record.txt --single-version-externally-managed --compile --install-headers [path-to-venv]/include/site/python3.4 failed with error code 1 in [path-to-venv]/build/cryptography
Storing debug log for failure in /home/webdev/.pip/pip.log

What's malfunctioning here and how to fix it?

Installing cryptography seems like a relatively straightforward thing to do with a virtual environment, but it's not working and I don't see any references to problems like this one anywhere online.

Update: the operating system type is Linux, and installation of cryptography works fine on the system itself. This problem only appears when attempting to install into a virtual environment.

murmur0m
  • 141
  • 1
  • 2
  • 9
  • `cryptography` usually requires some root level access to certain tools; if you don't have that, try `pip install --upgrade --user cryptography` and see if that works. – Danielle M. May 06 '18 at 18:58
  • What platform is this? If Mac OS X, you need to use homebrew to install libffi. See http://cffi.readthedocs.io/en/latest/installation.html#macos-x. You'll certainly need OpenSSL via brew. – Martijn Pieters May 06 '18 at 18:58
  • @DanielleM.: I never needed to do that, certainly not in a virtualenv. – Martijn Pieters May 06 '18 at 18:58
  • Yeah it was the permissions error that made me just want to see if output differed. Prob a waste of time in this case tho. – Danielle M. May 06 '18 at 19:02
  • @DanielleM.: it is *absolutely* a waste of time. The issue is not even with cryptography here. – Martijn Pieters May 06 '18 at 19:03
  • When I try to install the latest setuptools, the install returns error... ||| command: pip `install --upgrade --user setuptools==39.1.0` ||| error: `Will not install to the user site because it will lack sys.path precedence to setuptools in [path-to-venv]/lib/python3.4/site-packages` – murmur0m May 06 '18 at 19:11
  • @murmur0m: you do not need to go that way. `pip install --user` installs into an entirely different location. – Martijn Pieters May 06 '18 at 19:13
  • @Martijn Pieters: Platform is Linux, by the way. OpenSSL is already installed by root user. Systemwide environment version of cryptography for Python works fine as well. Problems only when installing for the virtual environment. – murmur0m May 06 '18 at 19:18
  • @DanielleM: Thanks for your suggestion. Any other ideas you might have are also welcome, even "wastes of time". If there's any chance of resolving the issue, that's what matters most here until we find an workable answer. – murmur0m May 06 '18 at 19:22
  • @murmur0m: I'm guessing that the wheel version, which bundles a libffi dynamic library, isn't compatible with your system, or some such problem. – Martijn Pieters May 06 '18 at 19:22
  • @Martijn Pieters I've tried directly copying `_cffi_backend.cpython-34m.so` into the site-packages directory... trying to install cryptography afterward returns error: `ImportError: libffi-8444b146.so.6.0.4: cannot open shared object file: No such file or directory`. How can an incompatible libffi dynamic library be changed to a compatible one? – murmur0m May 06 '18 at 19:47
  • at a guess, by installing the Python cffi library from source. – Martijn Pieters May 06 '18 at 20:23
  • I don't think that's the problem (but honestly, I have no idea). After installing the exact cffi version into the virtual environment (using `pip install cffi==1.11.5`), the error remains when attempting to install cryptography. Specifying the exact version number for cffi would install the correct library as well, right? – murmur0m May 06 '18 at 20:37
  • @Martijn Pieters I tried the solution you suggested... resulted in the same error. See this answer for details: https://stackoverflow.com/a/50204919/9749547 – murmur0m May 06 '18 at 22:01
  • @murmur0m: that's not what answers are for. You didn't compile anything, you just installed the wheel again. – Martijn Pieters May 06 '18 at 22:46
  • @Martijn Pieters Same error after installing and compiling libffi from source. The attempted solution has been posted to Pastebin, since it wouldn't fit as a comment and a moderator deleted the suggested answer (which still hasn't solved the problem): https://pastebin.com/nrhUJymt – murmur0m May 06 '18 at 23:17

1 Answers1

1

for me using virtualenv solved the problem create virtual environment by python3 -m virtualenv venv then install cryptography pip install cryptography

  • This is the correct answer. OP's issue is that he is building a virtual environment using `venv` instead of `virtualenv`. there are differences. here is a thread that describes the differences between virtual environment builders: https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe – Trevor McCormick Apr 15 '21 at 19:21