没错就是超级套娃😂,但是迫于实验精神【突发奇想】需要也只能强行往上套,然后就发现了很多很多很多...错误,下面是亲测有效的安装方法【⚠️容器的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
库:
- 2、查看
cd /usr/local/lib
- libssl.png
- 3、加载
libssl
库安装路径
- 3、加载
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. 大功告成,测试python3
及pip3
- pip3_test.png
- pip3_install_test.png
-
参考自libreSSL安装. ↩
网友评论