安装Python cryptography时因screamingsnakecase模块失败求助
安装cryptography库时Inflector编译失败的解决方案
问题描述
在Debian 11的全新virtualenv中安装HomeAssistant所需的Python cryptography库,执行pip install cryptography时出现编译错误,Inflector v0.11.4找不到screamingsnakecase模块,相关导入无法解析。
错误详情
Compiling Inflector v0.11.4 Running `rustc --crate-name inflector /home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on -C metadata=24d92325aeb54f99 -C extra-filename=-24d92325aeb54f99 --out-dir /home/ha/pip_tmp/pip-install-rlon2cnz/cryptography_70234a9f3a1d4c4e96ab4ab0fdb076c9/src/rust/target/release/deps -L dependency=/home/ha/pip_tmp/pip-install-rlon2cnz/cryptography_70234a9f3a1d4c4e96ab4ab0fdb076c9/src/rust/target/release/deps --cap-lints allow` error[E0583]: file not found for module `screamingsnakecase` --> /home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/cases/mod.rs:22:1 | 22 | pub mod screamingsnakecase; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: to create the module `screamingsnakecase`, create file "/home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/cases/screamingsnakecase.rs" or "/home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/cases/screamingsnakecase/mod.rs" error[E0432]: unresolved import `cases::screamingsnakecase::to_screaming_snake_case` --> /home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/lib.rs:62:5 | 62 | use cases::screamingsnakecase::to_screaming_snake_case; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `to_screaming_snake_case` in `cases::screamingsnakecase` error[E0432]: unresolved import `cases::screamingsnakecase::is_screaming_snake_case` --> /home/ha/.cargo/registry/src/github.com-1285ae84e5963aae/Inflector-0.11.4/src/lib.rs:63:5 | 63 | use cases::screamingsnakecase::is_screaming_snake_case; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `is_screaming_snake_case` in `cases::screamingsnakecase` Some errors have detailed explanations: E0432, E0583.
环境信息
Python: 3.9.2 platform: Linux-5.10.0-20-rt-armmp-armv7l-with-glibc2.31 pip: n/a setuptools: 66.0.0 setuptools_rust: 1.5.2 rustc: n/a
解决方案
- 清理Cargo缓存:执行
cargo clean,重新运行pip install cryptography,缓存的Inflector包可能损坏,缺少必要的模块文件。 - 指定cryptography版本:安装旧版本避免依赖有问题的Inflector,执行
pip install cryptography==38.0.4。 - 更新setuptools-rust:执行
pip install --upgrade setuptools-rust,确保Rust构建工具版本兼容,解决模块解析问题。 - 手动删除损坏的Inflector包:删除
.cargo/registry/src/github.com-*/Inflector-0.11.4目录,重新运行安装命令,让Cargo重新下载完整的包文件。
内容的提问来源于stack exchange,提问作者Mike
相关产品推荐
相关产品推荐

