这个教程完全是为了自己用的方便,教程总分为两项。
第一项:为使用docker容器的小伙伴,封装Python3.6.5的容器 ,依赖的基础容器是centos。直接上Dockerfile
FROM centos
MAINTAINER <zhang_hongzhuang@163.com>
RUN yum -y groupinstall 'Development Tools'
RUN yum -y install epel-release && \
yum -y install gcc && \
yum -y install zlib-devel && \
yum -y install bzip2-devel && \
yum -y install openssl-devel && \
yum -y install ncurses-devel && \
yum -y install wget && \
yum -y install zlib* && \
yum -y install sqlite-devel
ADD sqlite-autoconf-3230100.tar.gz /
RUN cd sqlite-autoconf-3230100 && \
./configure && \
make && \
make install
ADD Python-3.6.5.tgz /
RUN mkdir -p /usr/local/python3
RUN cd /Python-3.6.5/ && \
./configure --prefix=/usr/local/python3 --enable-optimizations && \
make && \
make install
RUN ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3 && \
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
RUN pip3 install --upgrade pip
完整的项目,在我的GitHub上 https://github.com/zhanghongzhuang/python3.6.5
第二项:这个sh脚本是直接运行在centons7服务器上,就可以拥有Python3.6.5的环境,你也可以使用pip3下载你需要的Python模块。
#/bin/bash
echo "安装变量"
yum clean all
yum makecache
yum -y groupinstall 'Development Tools'
yum -y install epel-release
yum -y install gcc
yum -y install zlib-devel
yum -y install bzip2-devel
yum -y install openssl-devel
yum -y install ncurses-devel
yum -y install wget
yum -y install zlib*
yum -y install sqlite-devel
echo "输出当前目录"
The_current=$(pwd)
echo $The_current
echo "解压./sqlite-autoconf-3230100.tar.gz,并安装"
tar xvzf ./sqlite-autoconf-3230100.tar.gz
cd sqlite-autoconf-3230100 &&./configure
make && make install
echo "创建Python3文件夹"
mkdir -p /usr/local/python3
cd $The_current
rm -rf ./sqlite-autoconf-3230100
echo "编译安装Python3.6.5"
tar xvzf ./Python-3.6.5.tgz
cd ./Python-3.6.5
./configure --prefix=/usr/local/python3 --enable-optimizations && make && make install
cd $The_current
rm -rf ./Python-3.6.5
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
echo "升级pip"
pip3 install --upgrade pip
完整的项目在GitHub上,https://github.com/zhanghongzhuang/python3.6.5
使用的方法:
进入到我的GitHub项目,然后clone下来,进到目录里面。
[root@localhost ~]# cd python3.6.5
[root@localhost python3.6.5]# ls
Dockerfile python3.6.5.sh Python-3.6.5.tgz README.md sqlite-autoconf-3230100.tar.gz
1)构建docker镜像需要
docker build -t python3.6.5 .
2)在centons服务器上直接搭建Python3.6.5环境。
./python3.6.5.sh