Search code examples
pythonlinuxpippython-cryptography

Issue installing cryptography on Raspberry Pi 2B (armv7h Arch Linux ARM) (python 3.9.8)


I'm having some trouble installing the python cryptography package on my raspberry pi, specifically with python version 3.9.8 (installed with pyenv). The cryptography package is installed on my system using pacman (python-cryptography package), and thus works using the main python interpreter (3.10.1). However, I need some version of python 3.9 specifically for another package I am using in this project. Any time I try to install cryptography through the python 3.9.8 environment, I get the following error:

Building wheels for collected packages: cryptography
  Building wheel for cryptography (pyproject.toml): started
  Building wheel for cryptography (pyproject.toml): finished with status 'error'
Failed to build cryptography

  ERROR: Command errored out with exit status 1:
   command: /home/kioskuser/.local/share/virtualenvs/Kivy-Raspi-Desktop-App-EzpaxvF4/bin/python /home/kioskuser/.local/share/virtualenvs/Kivy-Raspi-Desktop-App-EzpaxvF4/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp4zxk3vu2
       cwd: /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e
  Complete output (163 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-3.9
  creating build/lib.linux-armv7l-3.9/cryptography
  copying src/cryptography/utils.py -> build/lib.linux-armv7l-3.9/cryptography
  copying src/cryptography/fernet.py -> build/lib.linux-armv7l-3.9/cryptography
  copying src/cryptography/exceptions.py -> build/lib.linux-armv7l-3.9/cryptography
  copying src/cryptography/__init__.py -> build/lib.linux-armv7l-3.9/cryptography
  copying src/cryptography/__about__.py -> build/lib.linux-armv7l-3.9/cryptography
  creating build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/oid.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/ocsp.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/name.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/general_name.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/extensions.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/certificate_transparency.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/base.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  copying src/cryptography/x509/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/x509
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat
  copying src/cryptography/hazmat/_oid.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat
  copying src/cryptography/hazmat/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/poly1305.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/_serialization.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/_cipheralgorithm.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/_asymmetric.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings
  copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/twofactor
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/ssh.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/pkcs7.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/pkcs12.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/base.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/serialization
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/kdf
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/ciphers
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/x448.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/types.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ed448.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ed25519.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/primitives/asymmetric
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/openssl
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x448.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/poly1305.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ed448.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ed25519.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-armv7l-3.9/cryptography/hazmat/backends/openssl
  running egg_info
  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files found matching 'vectors'
  warning: no previously-included files matching '*' found under directory 'vectors'
  warning: no previously-included files matching '*' found under directory '.github'
  warning: no previously-included files found matching 'release.py'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching 'codecov.yml'
  warning: no previously-included files found matching '.readthedocs.yml'
  warning: no previously-included files found matching 'dev-requirements.txt'
  warning: no previously-included files found matching 'tox.ini'
  warning: no previously-included files found matching 'mypy.ini'
  warning: no previously-included files matching '*' found under directory '.zuul.d'
  warning: no previously-included files matching '*' found under directory '.zuul.playbooks'
  writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
  copying src/cryptography/py.typed -> build/lib.linux-armv7l-3.9/cryptography
  creating build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/_rust
  copying src/cryptography/hazmat/bindings/_rust/__init__.pyi -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/_rust
  copying src/cryptography/hazmat/bindings/_rust/asn1.pyi -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/_rust
  copying src/cryptography/hazmat/bindings/_rust/ocsp.pyi -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/_rust
  copying src/cryptography/hazmat/bindings/_rust/x509.pyi -> build/lib.linux-armv7l-3.9/cryptography/hazmat/bindings/_rust
  warning: build_py: byte-compiling is disabled, skipping.
  
  running build_ext
  cargo rustc --lib --manifest-path src/rust/Cargo.toml --release -v --features pyo3/abi3-py36 pyo3/extension-module -- --crate-type cdylib
     Compiling proc-macro2 v1.0.32
     Compiling unicode-xid v0.2.2
     Compiling syn v1.0.81
     Compiling autocfg v1.0.1
       Running `rustc --crate-name build_script_build --edition=2018 /home/kioskuser/.cargo/registry/src/github.com-1285ae84e5963aae/proc-macro2-1.0.32/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=7a95d32b66ae1a1f -C extra-filename=-7a95d32b66ae1a1f --out-dir /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/build/proc-macro2-7a95d32b66ae1a1f -L dependency=/tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps --cap-lints allow`
       Running `rustc --crate-name unicode_xid /home/kioskuser/.cargo/registry/src/github.com-1285ae84e5963aae/unicode-xid-0.2.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg 'feature="default"' -C metadata=2b7724452eebc032 -C extra-filename=-2b7724452eebc032 --out-dir /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps -L dependency=/tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps --cap-lints allow`
       Running `rustc --crate-name build_script_build --edition=2018 /home/kioskuser/.cargo/registry/src/github.com-1285ae84e5963aae/syn-1.0.81/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="extra-traits"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' -C metadata=6954389b44e215f9 -C extra-filename=-6954389b44e215f9 --out-dir /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/build/syn-6954389b44e215f9 -L dependency=/tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps --cap-lints allow`
       Running `rustc --crate-name autocfg /home/kioskuser/.cargo/registry/src/github.com-1285ae84e5963aae/autocfg-1.0.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on -C metadata=062cd71dd028816e -C extra-filename=-062cd71dd028816e --out-dir /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps -L dependency=/tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps --cap-lints allow`
  error: could not compile `unicode-xid`
  
  Caused by:
    process didn't exit successfully: `rustc --crate-name unicode_xid /home/kioskuser/.cargo/registry/src/github.com-1285ae84e5963aae/unicode-xid-0.2.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg 'feature="default"' -C metadata=2b7724452eebc032 -C extra-filename=-2b7724452eebc032 --out-dir /tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps -L dependency=/tmp/pip-install-c5oajf7r/cryptography_5c58967b948d4a78862f30763d6e3c9e/src/rust/target/release/deps --cap-lints allow` (signal: 4, SIGILL: illegal instruction)
  warning: build failed, waiting for other jobs to finish...
  error: build failed
  
      =============================DEBUG ASSISTANCE=============================
      If you are seeing a compilation error please try the following steps to
      successfully install cryptography:
      1) Upgrade to the latest pip and try again. This will fix errors for most
         users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
      2) Read https://cryptography.io/en/latest/installation/ for specific
         instructions for your platform.
      3) Check our frequently asked questions for more information:
         https://cryptography.io/en/latest/faq/
      4) Ensure you have a recent Rust toolchain installed:
         https://cryptography.io/en/latest/installation/#rust
  
      Python: 3.9.8
      platform: Linux-5.10.90-1-rpi-ARCH-armv7l-with-glibc2.32
      pip: n/a
      setuptools: 60.5.0
      setuptools_rust: 1.1.2
      =============================DEBUG ASSISTANCE=============================
  
  error: cargo failed with code: 101
  
  ----------------------------------------
  ERROR: Failed building wheel for cryptography
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects

✘ Installation Failed

So far I have tried:

  1. Upgrading pip (now version 21.3.1)
  2. Ensuring a rust compiler is installed (rustc version 1.57.0)
  3. Ensure libffi is installed (version 3.4.2)
  4. Ensure OpenSSL is installed (version 1.1.1)
  5. Being an Arch Linux system, I of course have gcc installed for a C compiler (version 10.2.0)
  6. Isolated the issue down to this package (I was initially trying to install cryptography as a dependency for msal)
  7. Tried using pipenv as well as navigating directly to the python executable in the ~/.pyenv/versions/3.9.8 directory
  8. In the ~/.pyenv/versions/3.9.8 directory, tried both using the pip executable there, as well as ./python -m pip for installation, with the same results both times.
  9. The above steps also included checking all 4 of the suggested debugging steps from the error message.

It might also be useful to note that all of this works perfectly in the virtual environment on my main system (also Arch Linux, but x86_64 rather than ARM).

What else can I try to get the cryptography package installed?

Alternatively, it looks like the same version of the library is installed in the main site packages through pacman, but that of course is not recognized by the virtual environment or by a separate version of python. Is there some way I can force python 3.9.8 to use that package instead?


Solution

  • @jakub's solution ended up solving the problem for me. I uninstalled the version of rust that was installed through pacman. To replace it, I installed rustup and then using rustup, installed the latest nightly version of rust (1.60). Once I did that, installing the cryptography package worked just fine.

    If you are using rustup, just make sure that you add ~/.cargo/bin to your PATH before installation. Also, the command I used to install rust through rustup was rustup toolchain install nightly.