错误:未编译 Python ssl 扩展。缺少 OpenSSL 库?

错误:未编译 Python ssl 扩展。缺少 OpenSSL 库?

我尝试在 Ubuntu 22.04 中通过 Pyenv 安装 python3.8.13,但出现以下错误:

kev@kev-Modern-15-A5M:~$ pyenv install 3.8.13
Installing Python-3.8.13...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

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


BUILD FAILED (Ubuntu 22.04 using python-build 20180424)

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

Last 10 log lines:
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmp_uhv2abg
Processing /tmp/tmp_uhv2abg/setuptools-56.0.0-py3-none-any.whl
Processing /tmp/tmp_uhv2abg/pip-22.0.4-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.8 are installed in '/home/kev/.pyenv/versions/3.8.13/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.0.4 setuptools-56.0.0

但是我之前已经安装过 OpenSSL

kev@kev-Modern-15-A5M:~$ openssl version -a
OpenSSL 1.1.1p  21 Jun 2022
built on: Tue Jun 21 13:39:39 2022 UTC
platform: linux-x86_64
options:  bn(64,64) md2(char) rc4(8x,int) des(int) idea(int) blowfish(ptr) 
compiler: gcc-5 -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG
OPENSSLDIR: "/home/linuxbrew/.linuxbrew/etc/[email protected]"
ENGINESDIR: "/home/linuxbrew/.linuxbrew/Cellar/[email protected]/1.1.1p/lib/engines-1.1"

答案1

在我的计算机上,当我运行

sudo apt install libssl-dev

答案2

再次尝试强制删除 brewed 版本的 openssl

brew uninstall --force openssl

然后清理所有旧版本并清除 brew 缓存

brew cleanup -s openssl

删除所有无效的符号链接

brew cleanup --prune-prefix

然后尝试重新安装 openssl

brew install openssl

相关内容