您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

忽略surepip失败pip在Ubuntu 18.04中要求ssl / tls错误

忽略surepip失败pip在Ubuntu 18.04中要求ssl / tls错误

这是由于Debian 9使用OpenSSL 1.1.0,然而,OpenSSL 1.1.0在SSL模块,支持只加入到了Python2.7.133.5.3并且3.6+ 因此,它使那些版本下的蟒蛇不能正确链接ssl库。问题https://github.com/pyenv/pyenv/issues/945 因此,在编译它们时必须手动添加这些库。

由于您的系统已经使用认的python进行编译,因此无意中将不同版本的python编译为global可执行文件可能会导致许多隐藏的问题,尤其是在系统认python后面使用的某些命令。

那么,为什么不使用pyenv来控制那些python版本呢?pyenv就像是一个Python版本的控制程序,它使用shims,通过一个名为老调重弹的过程,pyenv维持shims在该目录中跨的每一个安装的版本每个Python命令匹配pythonpip等。有关更多文档,请阅读:https ://github.com/pyenv/pyenv。要进行安装pyenv,请遵循提供的参考。

经过许多小时的努力,我终于找到了一种解决方案,可以完美地解决这些版本的python冲突问题,将以下脚本复制并粘贴到新文件中,并使其可执行,然后可以编译并安装这些python。如果您想以其他方式安装它们,例如,不使用pyenv,请更改最后第二行命令以适合您的需求。

#!/bin/bash -e

# Note: it is a script to solve Ubuntu 18.04 LTS 
#       different version of pythons compiling
#       header confliction problems
#
# The idea is got from @JustAnotherArivist
# From URL: https://github.com/pyenv/pyenv/issues/945
#
# The script used in here is with slightly modifications
# to fit many different SSL header versions


# First under your home directory make OpenSSL library
# and extract useful package

mkdir ~/libssl1.0-dev
cd ~/libssl1.0-dev
apt-get download libssl1.0-dev
ar x libssl1.0-dev* data.tar.xz
tar -xf data.tar.xz --strip-components=2


# Second, specifically get your current system's SSL headers
# and make symbolic-links

libcrypto=$(ls /usr/lib/x86_64-linux-gnu/ | grep libcrypto.so......)
libssl=$(ls /usr/lib/x86_64-linux-gnu/ | grep libssl.so......)

ln -s /usr/lib/x86_64-linux-gnu/${libcrypto} ~/libssl1.0-dev/lib/x86_64-linux-gnu
ln -s /usr/lib/x86_64-linux-gnu/${libssl} ~/libssl1.0-dev/lib/x86_64-linux-gnu


# Set your CFLAGS LDFLAGS compile options
# And use pyenv install the python version <3.4.5 or <3.5.3

# Note: it is a one line command
# Please change the version of python that you want to compile
CFLAGS="-I${HOME}/libssl1.0-dev/include -I${HOME}/libssl1.0-dev/include/x86_64-linux-gnu" \
LDFLAGS="-L${HOME}/libssl1.0-dev/lib/x86_64-linux-gnu" \
pyenv install 3.4.2


# Remove tempor libssl1.0-dev direcotory
rm -rf ~/libssl1.0-dev
其他 2022/1/1 18:40:15 有510人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶