---
slug: "python-cryptography-pep-517-rust-E0658"
title: "If You Can't Install Python Cryptography, Install Rust with rustup"
description: "Fix screen redraw issues when Mac Quick Look or Finder content is displayed on a DisplayLink-connected screen."
url: "https://www.ytyng.com/en/blog/python-cryptography-pep-517-rust-E0658"
publish_date: "2021-02-08T14:34:50Z"
created: "2021-02-08T14:34:50Z"
updated: "2026-05-11T13:21:51.227Z"
categories: ["Python"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20250605/52cae6aa3ecc42a5bc0809434e478387.png.webp?width=768"
has_video: true
has_music: true
video_urls: ["https://media.ytyng.net/ytyng-blog/192/featured-video-1.mp4", "https://media.ytyng.net/ytyng-blog/192/featured-video-2.mp4", "https://media.ytyng.net/ytyng-blog/192/featured-video-3.mp4"]
music_urls: ["https://media.ytyng.net/ytyng-blog/192/featured-music-192-3.mp3", "https://media.ytyng.net/ytyng-blog/192/featured-music-192-4.mp3"]
lang: "en"
---

# If You Can't Install Python Cryptography, Install Rust with rustup

<p>Pipenv install in the Dockerfile of Alpine is failing.</p>
<p>The installation of cryptography 3.4.1 fails with the error: ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly.</p>
<p></p>
<p>As a test, instead of using pipenv,</p>
<p>try pip install cryptography</p>
<p></p>
<pre>#10 32.68 [pipenv.exceptions.InstallError]: Collecting cryptography>=1.4<br />#10 32.68 [pipenv.exceptions.InstallError]: Using cached cryptography-3.4.4.tar.gz (545 kB)<br />#10 32.68 [pipenv.exceptions.InstallError]: ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of setuptools.build_meta in pyproject.toml</pre>
<pre> generating cffi module 'build/temp.linux-x86_64-3.8/_padding.c'<br /> creating build/temp.linux-x86_64-3.8<br /> generating cffi module 'build/temp.linux-x86_64-3.8/_openssl.c'<br /> running build_rust<br /> <br /> =============================DEBUG ASSISTANCE=============================<br /> If you are seeing a compilation error please try the following steps to<br /> successfully install cryptography:<br /> 1) Upgrade to the latest pip and try again. This will fix errors for most<br /> users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip<br /> 2) Read https://cryptography.io/en/latest/installation.html for specific<br /> instructions for your platform.<br /> 3) Check our frequently asked questions for more information:<br /> https://cryptography.io/en/latest/faq.html<br /> 4) Ensure you have a recent Rust toolchain installed.<br /> =============================DEBUG ASSISTANCE=============================<br /> <br /> error: Can not find Rust compiler<br /> ----------------------------------------<br /> ERROR: Failed building wheel for cryptography<br />Failed to build cryptography<br />ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly<br />/ # </pre>
<p>It requires Rust.</p>
<p>The current version is cryptography 3.4.1, which now requires building with Rust.</p>
<p></p>
<p>According to the FAQ:</p>
<p><a href="https://cryptography.io/en/latest/faq.html">https://cryptography.io/en/latest/faq.html</a></p>
<p></p>
<p>For this version, it seems that setting the environment variable CRYPTOGRAPHY_DONT_BUILD_RUST allows building without Rust.</p>
<p>This should be the last resort.</p>
<p></p>
<p>Let's try installing rust and cargo:</p>
<p></p>
<p>apk add rust cargo</p>
<p>Then,</p>
<p>pip install cryptography</p>
<pre> Running `rustc --crate-name parking_lot_core --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot_core-0.8.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=eee97183f997b675 -C extra-filename=-eee97183f997b675 --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern cfg_if=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libcfg_if-cac6a3fe3e67c31f.rmeta --extern instant=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libinstant-8d8e286f6640e0bb.rmeta --extern libc=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/liblibc-7eee26158fb5ebc8.rmeta --extern smallvec=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsmallvec-4a190f9a26ad8e9a.rmeta --cap-lints allow -C target-feature=-crt-static`<br /> Running `rustc --crate-name syn --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.60/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --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=e836c33ca097f1fb -C extra-filename=-e836c33ca097f1fb --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern unicode_xid=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libunicode_xid-13530667aae58aae.rmeta --cap-lints allow -C target-feature=-crt-static --cfg syn_disable_nightly_tests`<br /> Compiling parking_lot v0.11.1<br /> Running `rustc --crate-name parking_lot --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.11.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="default"' -C metadata=01e553f69513271f -C extra-filename=-01e553f69513271f --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern instant=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libinstant-8d8e286f6640e0bb.rmeta --extern lock_api=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/liblock_api-8e10e3c848fbd6d6.rmeta --extern parking_lot_core=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libparking_lot_core-eee97183f997b675.rmeta --cap-lints allow -C target-feature=-crt-static`<br /> Running `/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/build/pyo3-089b3f9e5ef423ad/build-script-build`<br /> Compiling pyo3-macros-backend v0.13.1<br /> Running `rustc --crate-name pyo3_macros_backend --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=1c47d36fb0c032da -C extra-filename=-1c47d36fb0c032da --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern syn=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsyn-e836c33ca097f1fb.rmeta --cap-lints allow -C target-feature=-crt-static`<br /> error[E0658]: use of unstable library feature 'str_strip': newly added<br /> --&gt; /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/method.rs:144:18<br /> |<br /> 144 | .strip_prefix(prefix)<br /> | ^^^^^^^^^^^^<br /> |<br /> = note: see issue #67302 &lt;https://github.com/rust-lang/rust/issues/67302&gt; for more information<br /> <br /> error: aborting due to previous error<br /> <br /> For more information about this error, try `rustc --explain E0658`.<br /> error: could not compile `pyo3-macros-backend`.<br /> <br /> Caused by:<br /> process didn't exit successfully: `rustc --crate-name pyo3_macros_backend --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=1c47d36fb0c032da -C extra-filename=-1c47d36fb0c032da --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern syn=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsyn-e836c33ca097f1fb.rmeta --cap-lints allow -C target-feature=-crt-static` (exit code: 1)<br /> warning: build failed, waiting for other jobs to finish...<br /> error: build failed<br /> <br /> =============================DEBUG ASSISTANCE=============================<br /> If you are seeing a compilation error please try the following steps to<br /> successfully install cryptography:<br /> 1) Upgrade to the latest pip and try again. This will fix errors for most<br /> users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip<br /> 2) Read https://cryptography.io/en/latest/installation.html for specific<br /> instructions for your platform.<br /> 3) Check our frequently asked questions for more information:<br /> https://cryptography.io/en/latest/faq.html<br /> 4) Ensure you have a recent Rust toolchain installed.<br /> =============================DEBUG ASSISTANCE=============================<br /> <br /> error: cargo failed with code: 101<br /> <br /> ----------------------------------------<br /> ERROR: Failed building wheel for cryptography<br />Failed to build cryptography<br />ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly<br />/ # </pre>
<p></p>
<pre>error[E0658]: use of unstable library feature 'str_strip': newly added</pre>
<p>This error occurred.</p>
<p>Upon further investigation, it seems that using rustup instead of installing rust and cargo via apk is recommended.</p>
<p></p>
<p><a href="https://rustup.rs/">https://rustup.rs/</a></p>
<p></p>
<p>apk add curl</p>
<p>curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh</p>
<p></p>
<pre>/ # curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh<br />info: downloading installer<br /><br />Welcome to Rust!<br /><br />This will download and install the official compiler for the Rust<br />programming language, and its package manager, Cargo.<br /><br />Rustup metadata and toolchains will be installed into the Rustup<br />home directory, located at:<br /><br /> /root/.rustup<br /><br />This can be modified with the RUSTUP_HOME environment variable.<br /><br />The Cargo home directory located at:<br /><br /> /root/.cargo<br /><br />This can be modified with the CARGO_HOME environment variable.<br /><br />The cargo, rustc, rustup and other commands will be added to<br />Cargo's bin directory, located at:<br /><br /> /root/.cargo/bin<br /><br />This path will then be added to your PATH environment variable by<br />modifying the profile file located at:<br /><br /> /root/.profile<br /><br />You can uninstall at any time with rustup self uninstall and<br />these changes will be reverted.<br /><br />Current installation options:<br /><br /><br /> default host triple: x86_64-unknown-linux-musl<br /> default toolchain: stable (default)<br /> profile: default<br /> modify PATH variable: yes<br /><br />1) Proceed with installation (default)<br />2) Customize installation<br />3) Cancel installation<br />&gt;1<br /><br />info: profile set to 'default'<br />info: default host triple is x86_64-unknown-linux-musl<br />info: syncing channel updates for 'stable-x86_64-unknown-linux-musl'<br />info: latest update on 2020-12-31, rust version 1.49.0 (e1884a8e3 2020-12-29)<br />info: downloading component 'cargo'<br />info: downloading component 'clippy'<br />info: downloading component 'rust-docs'<br /> 13.9 MiB / 13.9 MiB (100 %) 6.7 MiB/s in 2s ETA: 0s<br />info: downloading component 'rust-std'<br /> 21.5 MiB / 21.5 MiB (100 %) 6.8 MiB/s in 3s ETA: 0s<br />info: downloading component 'rustc'<br /> 76.9 MiB / 76.9 MiB (100 %) 7.2 MiB/s in 11s ETA: 0s<br />info: downloading component 'rustfmt'<br />info: installing component 'cargo'<br />info: using up to 
