ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

ubuntu 22.04 build python 3.x error:

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.20220629172729.3400406
Results logged to /tmp/python-build.20220629172729.3400406.log
  1. 使用自己下载编译的openssl库
LDFLAGS="-L/opt/openssl/lib -Wl,-rpath,/opt/openssl/lib" CONFIGURE_OPTS="--with-openssl=/opt/openssl --enable-optimizations" pyenv install 3.10.4
  1. 使用brew安装的openssl库
LDFLAGS="-Wl,-rpath,=$(brew --prefix openssl@1.1)/lib" CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl@1.1) --enable-optimizations" pyenv install 3.10.0