这个问题是基于Python HTTPS download fails due to ""的,其中我可以将构建错误<urlopen error unknown url type: https>解析为<urlopen error [SSL: NO_CIPHERS_AVAILABLE] no ciphers available (_ssl.c:661)>。
我正在尝试在一个非常小的系统(Ubuntu16.04 docker image)上从源代码构建一个Python2.7,它不会因为<urlopen error [SSL: NO_CIPHERS_AVAILABLE] no ciphers available (_ssl.c:661)>而导致HTTPS下载失败。我不想使用包管理器和预先构建的docker镜像,但我知道这很容易解决问题。
构建脚本是
apt-get update && apt-get install --yes wget xz-utils make gcc patch && rm -rf /var/lib/apt/lists/*
wget http://www.cpan.org/src/5.0/perl-5.26.1.tar.gz && tar xf perl-5.26.1.tar.gz && cd perl-5.26.1 && ./configure.gnu && make -j16 && make install && cd .. && rm perl-5.26.1.tar.gz
wget https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz && tar xf gettext-0.19.8.1.tar.xz && cd gettext-0.19.8.1 && ./configure && make -j16 && make install && cd .. && rm gettext-0.19.8.1.tar.xz
wget https://www.zlib.net/zlib-1.2.11.tar.gz && tar xf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && ./configure && make -j16 && make install && cd .. && rm zlib-1.2.11.tar.gz
wget https://www.kernel.org/pub/software/scm/git/git-2.13.3.tar.gz && tar xf git-2.13.3.tar.gz && cd git-2.13.3 && ./configure --with-perl=/usr/local/bin/perl && make -j16 && make install && cd .. && rm git-2.13.3.tar.gz
# need `--with-perl` passed to `configure` because the `/usr/local/bin/perl` isn't picked up regardless where it's found in PATH, see https://stackoverflow.com/questions/48931247/cant-locate-extutils-makemaker-pm-in-inc-during-git-build for details
wget https://www.openssl.org/source/openssl-1.1.1-pre1.tar.gz && tar xf openssl-1.1.1-pre1.tar.gz && rm openssl-1.1.1-pre1.tar.gz
wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz && tar xf Python-2.7.14.tgz && rm Python-2.7.14.tgz
git clone git://git.gnome.org/jhbuild
cp -a /openssl-1.1.1-pre1 . && cd openssl-1.1.1-pre1 && ./config --prefix=/usr/local/ --openssldir=/usr/local && make -j16 && make install && cd ..
# need to install into explicit prefix different from `/usr/local` in order to make OpenSSL get picked up by Python's patched `configure` (specifying `OPENSSL_ROOT=/usr/local` doesn't work)
ldconfig
# avoids `./python: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory` during build of Python
cp -a /Python-2.7.14 . && cd Python-2.7.14 && wget https://gist.githubusercontent.com/rkitover/2d9e5baff1f1cc4f2618dee53083bd35/raw/7f33fcf5470a9f1013ac6ae7bb168368a98fe5a0/python-2.7.14-custom-static-openssl.patch && patch -p1 <python-2.7.14-custom-static-openssl.patch && patch -u -p0 <../setup.patch && cp Modules/Setup.dist Modules/Setup && env OPENSSL_ROOT=/usr/local ./configure && make -j16 && make install && cd ..
cp -a /jhbuild . && cd jhbuild && ./autogen.sh --prefix=/usr/local && make && make install && cd ..
env JHBUILD_RUN_AS_ROOT= jhbuild bootstrap我选择jhbuild bootstrap作为测试命令,因为这是期望的结果,请随意建议一个更好的结果。这个构建脚本看起来很奇怪,因为我提取了一个Docker镜像krichter/ubuntu-git,它可以在https://gitlab.com/krichter/ubuntu-git上找到。
我在https://gitlab.com/krichter/jhbuild-docker-build上创建了一个SSCCE,它允许在GitLab CI中运行构建脚本,并且可以在https://gitlab.com/krichter/jhbuild-docker-build/-/jobs/53978734上研究一个包含完整构建日志的示例运行。
发布于 2019-05-20 05:37:29
为了在Mac上克服这个错误(以及其他错误),我使用Anaconda3创建了一个python2.7环境并安装了jhbuild依赖项(python2.7模块):
conda create -n py2 python=2.7
conda activate py2
conda install openssl xz gettext autoconf automake libtool m4 zip zlib
alias python2=python如果你只是想克服你的SSL错误,你只需要确保你的python --version和python2 --version都是2.7。然后,您需要在该python中安装最新的openssl,例如conda install openssl。我还没有尝试过pip install --upgrade openssl,但也许它也能起作用。
https://stackoverflow.com/questions/48941028
复制相似问题