Docker中离线配置python环境

----------------------------------------------------------环境
纯净centos7镜像离线安装
rpm包下载地址 https://pkgs.org/download
----------------------------------------------------------
各种命令不能使用就直接下载rpm安装
----------------------------------------------------------
systemctl无法使用
启动方式
docker run -itd --privileged=true centos7.4etl:latest /usr/sbin/init
进入方式
docker exec -it 28675a259296 bash
----------------------------------------------------------安装python

tar xvf Python-3.7.1.tar.xz
-----
cd Python-3.7.1
./configure
vim Modules/Setup
找到下面这句,去掉注释#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
一定要make clean清除缓存
make && make install
-----没有_ssl

为机器安装OpenSSL,
然后执行
./configure --prefix='/user/Python-3.7.1/' --with-ssl
vim Modules/Setup
#修改结果如下:
# Socket module helper for socket(2)
#_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
--------------------------------
./configure
一定要make clean清除缓存
make && make install

------------------------------python安装外部包
安装whl包: pip install **.whl(前提是要安装好pip和wheel)
安装tar.gz包:cd到解压后路径,python setup.py install(安装pip和wheel都可以参照这种方法)
pip3 install --no-index --find-links=/user/pythonlib/z1 -r requirements.txt 使用requirements.txt安装
注意要是安装失败可以单独把失败的包使用tar.gz安装,win操作系统独有的就不能安装,其他安装包一定要是操作系统支持的

posted @ 2018-12-28 16:06  巴啦啦大魔王  阅读(568)  评论(0编辑  收藏  举报