build\temp.win-amd64-cpython-310\Release\_openssl.c(575): fatal error C1083: 无法打开包括文件: “openssl/opensslv.h”: No such file or directory
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects
网络上搜索的 复制 phenssl 下的libs 文件没有效果
安装 pyproject.toml 后 也没有效果
基于Monster 组和GPT的调写:
在 Windows 上,你可以下载 OpenSSL for Windows 并安装。在 Linux 上,你可以使用你的发行版的包管理器安装 OpenSSL。
设置环境变量 LIBRARY_PATH 和 INCLUDE。在 Windows 上,打开 PowerShell 并运行以下命令:
$env:LIBRARY_PATH="C:\OpenSSL-Win64\lib\VC\static"
$env:INCLUDE="C:\OpenSSL-Win64\include"
这里假设你的 OpenSSL 安装在 C:\OpenSSL-Win64 目录下。在 Linux 上,你可以使用以下命令:
export LIBRARY_PATH=/usr/local/ssl/lib
export INCLUDE=/usr/local/ssl/include
这里假设你的 OpenSSL 安装在 /usr/local/ssl 目录下。
重新运行安装命令。在你的 Python 虚拟环境中,运行以下命令安装 cryptography:
pip install cryptography==2.8
如果上述步骤不起作用,你可以尝试升级到最新版本的 cryptography 或者安装较早的版本。也可以考虑安装 Anaconda 或 Miniconda,并使用 conda 来安装 cryptography。
检查下是不是没装没装libssl-dev和libffi-dev安装后再装cryptography2.8
参考
重新安装一下cryptography库呢
pip install --no-binary cryptography cryptography
解决方法:
这个错误通常是由于缺少 OpenSSL 库文件导致的。cryptography 库是一个基于 OpenSSL 库的 Python 加密模块,因此在安装 cryptography 时需要先安装 OpenSSL 库。
以下是一些可能的解决方案:
1、安装 OpenSSL 库
您可以从 OpenSSL 官方网站上下载并安装 OpenSSL 库:www。openssl。org/source/。安装完 OpenSSL 库后,再次尝试安装 cryptography 库。
2、指定 OpenSSL 库的位置
如果您已经安装了 OpenSSL 库,但安装仍然失败,则可能是由于 OpenSSL 库未正确配置。您可以尝试使用以下命令来指定 OpenSSL 库的位置:
pip install cryptography==2.8 --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"
根据您的操作系统和 OpenSSL 库的安装位置,上述命令中的参数可能会有所不同。
3、使用 conda 安装
如果您使用的是 Anaconda 或 Miniconda 等 Python 发行版,可以尝试使用 conda 安装 cryptography 库:
conda install cryptography=2.8
conda 会自动安装 OpenSSL 库及其依赖项。
希望这些解决方案能帮助您解决问题。
可以参考下这个实例【Windows 环境下 Python3 安装 cryptography】,链接:https://blog.csdn.net/xiaokurong/article/details/116642767
【博文讲解博主在安装过程中遇到的问题和解决办法,可为借鉴】
这个错误提示是缺少 OpenSSL 头文件,可能是因为缺少 OpenSSL 库或者安装位置不在编译器默认的路径中导致的。您可以尝试以下方法来解决该问题:
1.安装 OpenSSL 库:请确保已经正确安装 OpenSSL 库。您可以从官网下载最新版本的 OpenSSL 库,并根据系统类型安装相应的版本。安装完成后,请将 OpenSSL 库的安装路径添加到 PATH 环境变量中。
2.指定 OpenSSL 库的安装路径:您可以尝试使用openssl_root参数指定 OpenSSL 库的安装路径,例如:
pip install cryptography==2.8 --global-option=build_ext --global-option="-L<path_to_openssl_libraries>" --global-option="-I<path_to_openssl_headers>"
其中 '和后面的需要按照实际安装路径填入
3.使用已编译好的二进制文件:如果您使用的是 Windows 平台,可以从第三方网站下载已编译好的 cryptography 二进制文件,然后使用以下命令进行安装:
pip install <path_to_downloaded_wheel_file>
其中 '需要用户自己选择
希望这些方法能够帮助您解决问题。
这个错误通常是因为缺少 OpenSSL 库导致的。你可以按照以下步骤尝试解决该问题:
1.确认 OpenSSL 是否已经安装,如果没有安装可以前往 OpenSSL 官网下载并安装。
2.如果 OpenSSL 已经安装,请检查 OpenSSL 是否被正确安装并添加到环境变量中。你可以使用以下命令检查:
openssl version
如果成功输出 OpenSSL 版本信息,说明 OpenSSL 已经成功安装并添加到环境变量中。
3.如果 OpenSSL 已经安装且环境变量已经正确配置,你可以尝试升级 pip 和 setuptools,然后再次尝试安装 cryptography:
pip install --upgrade pip setuptools
pip install cryptography==2.8
如果上述方法都无法解决问题,你可以尝试卸载 cryptography,然后重新安装:
pip uninstall cryptography
pip install cryptography==2.8
如果仍然无法解决问题,你可以尝试安装较旧版本的 cryptography,或者考虑升级或降级 Python 版本。