忽略surepip故障pip在Ubuntu 18.04中要求ssl/tls错误 [英] ignoring ensurepip failure pip requires ssl/tls error in Ubuntu 18.04

查看:170
本文介绍了忽略surepip故障pip在Ubuntu 18.04中要求ssl/tls错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Ubuntu 18.04

尝试运行sudo make install会遇到上述错误.

Trying to run sudo make install gets the above error.

# Download Python
curl -O https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz
tar -xzvvf Python-3.4.2.tgz
cd Python-3.4.2
export CFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib -I/usr/local/opt/zlib/include -L/usr/local/opt/zlib/lib"

# Required Dependencies
sudo apt-get install libssl-dev openssl
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libpq-dev zlib1g-dev

# Prepare to install Python
./configure
make -j4
sudo make install

推荐答案

这是由于Debian 9使用OpenSSL 1.1.0.但是,SSL模块中的OpenSSL 1.1.0支持仅添加到Python 2.7.133.5.33.6+ 因此,这使得这些版本下的python无法正确链接到ssl库.问题 https://github.com/pyenv/pyenv/issues/945 因此,在编译它们时必须手动添加这些库.

This is due to Debian 9 using OpenSSL 1.1.0., However, OpenSSL 1.1.0 support in the SSL module was only added to Python 2.7.13, 3.5.3 and 3.6+ Thus, it makes the python under those versions cannot be correctly linked to ssl library. Issues https://github.com/pyenv/pyenv/issues/945 So you have to manually add those libraries when you are compiling them.

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

Since your system is already compiled with the default python, unintentionally compiled different version of python into global executable may cause many hidden problems, especially some commands used behind on system-default python.

那么为什么不使用pyenv来控制那些python版本呢? pyenv就像python版本的控制程序一样,它使用shims,通过称为重新哈希处理的过程,pyenv在该目录中维护shims,以匹配每个python,依此类推. 有关更多文档,请阅读: https://github.com/pyenv/pyenv . 要安装pyenv,请遵循提供的参考.

So why not you use pyenv, to control those version of pythons? pyenv is like a python-version control programs, it uses shims, through a process called rehashing, pyenv maintains shims in that directory to match every Python command across every installed version of python, pip, and so on. For more documents, please reading: https://github.com/pyenv/pyenv. To install pyenv, please following the provided reference.

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

After many hours struggling, I finally found a solution to perfectly solve those version of pythons confliction problems, copy and paste the following script to a new file, and make it executable, then you can compile and install those pythons. While if you want to install them in other way, say, without using pyenv, please change the last second line commands to fit your needs.

#!/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

这篇关于忽略surepip故障pip在Ubuntu 18.04中要求ssl/tls错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆