Centos7使用pyenv安装问题

问题描述 投票:0回答:1

大家好,我在使用“pyenv install 3.11.0”安装 Python 版本 3.11.0 时遇到错误

我已经安装了 openssl-devel,尝试了 Google 的所有方法来解决这个问题。这里有吗 遇到这个问题并解决吗?

我尝试安装“pyenv 3.9.0”并且成功,没有任何问题。

提前谢谢您

错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/<user>/.pyenv/versions/3.11.0/lib/python3.11/ssl.py", line 100, in <module>
    import _ssl             # If we can't import it, let the error propagate
    ^^^^^^^^^^^
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python SSL extension was not compiled. Missing the OpenSSL lib?

Please consult the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (CentOS Linux 7 using python-build 2.3.18)

Inspect or clean up the working tree at /tmp/python-build.20230601095845.30587
Results logged to /tmp/python-build.20230601095845.30587.log

Last 10 log lines:
    LD_LIBRARY_PATH=/tmp/python-build.20230601095845.30587/Python-3.11.0 ./python -E -m ensurepip \
        $ensurepip --root=/ ; \


Try to uninstall and install OpenSSL
python-3.x centos7 pyenv
1个回答
0
投票

安装 OpenSSL 开发库:确保您的系统上安装了 OpenSSL 开发库。您提到您已经尝试安装 openssl-devel,但请确保它已正确安装和更新。

指定 OpenSSL 前缀:有时,pyenv 可能无法正确检测 OpenSSL。您可以尝试在 Python 安装期间显式指定 OpenSSL 前缀。首先,通过运行以下命令找出 OpenSSL 在您系统上的位置:

which openssl

它应该为您提供 OpenSSL 二进制文件的路径。然后,在安装Python时,将OPENSSL_PREFIX环境变量设置为OpenSSL安装目录:

export OPENSSL_PREFIX=/path/to/openssl
pyenv install 3.11.0

重建Python:如果您在安装Python后已经安装了OpenSSL,则可能需要重建Python。尝试卸载有问题的 Python 版本,然后重新安装:

pyenv uninstall 3.11.0
pyenv install 3.11.0

查阅 Pyenv Wiki:Pyenv wiki 提供常见的构建问题和解决方案。请参阅其他故障排除步骤:Pyenv Wiki。

检查系统依赖项:确保安装了所有必需的系统依赖项。除了 OpenSSL 之外,Python 可能还需要其他开发库,如 zlib、libffi 等。请检查 Pyenv wiki 或 Python 文档,了解您的 Python 版本所需的特定依赖项。

检查日志:查看失败的构建过程中生成的日志。他们可能会提供有关出错原因和构建过程失败位置的更详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.