美文网首页
在Ubuntu 16.04中给Docker构建的Ubuntu容器

在Ubuntu 16.04中给Docker构建的Ubuntu容器

作者: AuraMIXdopE | 来源:发表于2020-03-30 00:28 被阅读0次

    没错就是超级套娃😂,但是迫于实验精神【突发奇想】需要也只能强行往上套,然后就发现了很多很多很多...错误,下面是亲测有效的安装方法【⚠️容器的Ubuntu未安装一切必要依赖,在MacBook Pro 2017上通过】

    1. 安装gcc编译器

    # 由虚拟机进入容器
    1. sudo docker exec -it test_1 /bin/bash
    
    # apt更新
    # 报错则用apt-get update --bfix-missing
    2. apt update
    
    # 安装gcc
    # 查看gcc版本信息:gcc --version
    ###### 此步骤时间较长
    3. apt install build-essential
    

    2.安装Python3

    2.1 在官网下载源码Python-3.x.x.tgz并将源码由虚拟机复制到容器目录下

    # sudo docker cp src container_name/id:path_to_python
    sudo docker cp Python-3.7.6.tgz test_1:/home/python3
    

    2.2 进入容器对应目录进行make安装【错误来袭】

    # make时可能会报错缺少zlib,先安装zlib及其依赖
    apt install zlibc zlib1g-dev
    make && make install
    
    • 按如下步骤安装
      1.tar -zxvf Python-3.x.x.tgz
      2.cd Python-3.x.x
      3../configure
      4.make && make install
      👆有两个语句会有问题【利用pip3安装其他python包时会有ssl证书问题】,问题及解决方法👇

    【问题1】SSL证书问题,不能连接到网站

    Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")
    
    • 解决方法:在安装时加上--with-ssl,即3、4步变为
    ./configure --with-ssl
    make && make install
    

    【问题2】SSL版本过低

    Could not build the ssl module! Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
    
    • 原因:在Python3.7之后的版本,依赖的openssl,必须要是1.1或者1.0.2之后的版本,或者2.6.4之后的libressl
    • 解决方法:安装libressl-2.7.4,在这里下载,可能需要先安装vim[1]
      • 1、解压源代码并make
    tar -zxvf libressl-2.7.4.tar.gz
    cd libreSSL-2.7.4
    ./config –prefix=/usr/local/lib
    make && make install
    
      • 2、查看libssl库:
    cd /usr/local/lib
    
    • libssl.png
      • 3、加载libssl库安装路径
    1. cd /etc/ld.so.conf.d
    
    # 新建文件,将libssl库安装路径加入文件中,保存并退出
    # 文件内容: /usr/local/lib
    2. vim libressl-2.7.4.conf 
    
    3. 执行 ldconfig -v  重新加载库文件
    4. 查看openssl的版本:openssl version
    

    【问题3】缺少_ctypes模块

    No module named '_ctypes'
    
    • 解决方法:apt install libffi-dev

    3. 大功告成,测试python3pip3

    • pip3_test.png
    • pip3_install_test.png

    1. 参考自libreSSL安装.

    相关文章

      网友评论

          本文标题:在Ubuntu 16.04中给Docker构建的Ubuntu容器

          本文链接:https://www.haomeiwen.com/subject/ixrpuhtx.html