1. 程式人生 > >Docker中離線配置python環境

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作業系統獨有的就不能安裝,其他安裝包一定要是作業系統支援的