在树莓派ARM64下用pyenv安装python3.7.4版本时出现错误无法安装.运行pyenv install -v 3.7.4,x显示ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib.
通过apt指令openssl时出现了相关库版本过关,无法安装的情况。linux就是这样,apt安装简单,但是遇到指定Lib版本时经常出现打架的情况。
解决方法
查询资料官方已经给出解决方案:https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib ,Pass the location of its headers and libraries explicitly:
CPPFLAGS="-I<openssl install prefix>/include" \
LDFLAGS="-L<openssl install prefix>/lib" \
pyenv install -v <python version>
or, alternatively, for Python 3.7+, instead of CPPFLAGS and LDFLAGS:
CONFIGURE_OPTS="--with-openssl=<openssl install prefix>"
具体解决步骤,参考https://blog.csdn.net/baidu_36146918/article/details/99838232 ,下载openssl-1.0.2j源文件,编译后并设置环境变量,解决python3.7.4的安装。
wget http://www.openssl.org/source/openssl-1.0.2j.tar.gz
tar -xzf openssl-1.0.2j.tar.gz
cd openssl-1.0.2j
./config shared zlib
./config -t
make
make install
cd /usr/local/ssl/lib
ldconfig -v
# 把下方新的ssl环境变量导入到.bashrc
LD_RUN_PATH="/usr/local/ssl/lib" \
LDFLAGS="-L/usr/local/ssl/lib" \
CPPFLAGS="-I/usr/local/ssl/include" \
CFLAGS="-I/usr/local/ssl/include" \
CONFIGURE_OPTS="--with-openssl=/usr/local/ssl" \
pyenv install 3.7.1