【问题标题】:ignoring ensurepip failure pip requires ssl/tls error in Ubuntu 18.04在 Ubuntu 18.04 中忽略 ensurepip 失败 pip 需要 ssl/tls 错误
【发布时间】:2018-05-02 03:41:35
【问题描述】:

Ubuntu 18.04

中尝试安装 python 和 pip 时出现 ignoring ensurepip failure pip requires ssl/tls 错误

尝试运行sudo make install 得到上述错误。

# 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

【问题讨论】:

  • 您找到解决方案了吗?我遇到了同样的问题。
  • @Benjamin 不,我没明白

标签: python ubuntu pip


【解决方案1】:

这是一个python编译问题,一直是fixed as of Python 3.4.5。最佳做法是升级到 3.4.5 并再次按照编译步骤操作。

对于那些来到这里的 Python here)。

我不确定其他 Python 版本是否受到影响,但在补丁说明中看到,在以后的版本中还对 Windows 和 MacOSX 进行了修复。请检查您正在使用的 Python 主要版本的更改日志,以查看适用于您的修复程序。更改日志可以在这里找到:(Python 3.4, Python 3.5)

【讨论】:

    【解决方案2】:

    这是由于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 因此,您必须在编译时手动添加这些库。

    我的建议

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

    那么为什么不使用pyenv 来控制这些版本的python? pyenv 就像一个 python 版本控制程序,它使用shims,通过一个称为 rehashing 的过程,pyenv 在该目录中维护shims,以匹配每个已安装版本的python、@987654337 中的每个 Python 命令@, 等等。 更多文档请阅读: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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 2017-04-27
      • 2018-04-15
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多