Dockerfile 下安装Python3.7.4 环境命令

Dockerfile 下安装Python3.7.4 环境命令

Linux 环境下安装Python3.7.4

sudo yum -y install zlib-devel 
sudo yum -y install bzip2-devel 
sudo yum -y install libffi-devel 
sudo yum -y install openssl-devel 
sudo yum -y install ncurses-devel 
sudo yum -y install sqlite-devel 
sudo yum -y install readline-devel 
sudo yum -y install tk-devel 
sudo yum -y install gcc make wget
sudo wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
sudo make dir /usr/local/python3
cd /usr/local/python3
sudo tar -xvJf  Python-3.7.4.tar.xz
cd Python-3.7.4
sudo ./configure prefix=/usr/local/python3
sudo make
sudo make install
sudo ln -s /usr/local/python3/bin/python3.7 /usr/local/bin/python3 
sudo ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 

Dockerfile命令安装Python3.7.4

在你的Dockerfile同级目录下下载好Python3.7.4的安装包
如图所示:

在这里插入图片描述

然后进入Dockerfile文件添加以下命令:

vim Dockerfile
RUN set -ex \
	&& yum -y install zlib-devel bzip2-devel libffi-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \
	&& yum clean all \
	&& mkdir /usr/local/python3 

COPY Python-3.7.4.tar.xz  /usr/local/python3/ 

RUN set -ex \
	&& cd /usr/local/python3 \
	&& tar -xvJf  Python-3.7.4.tar.xz \
	&& cd Python-3.7.4 \
	&& ./configure prefix=/usr/local/python3 \
	&& make && make install \
	&& ln -s /usr/local/python3/bin/python3.7 /usr/local/bin/python3 \
	&& ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 
	
RUN set -ex \
	&& cd /usr/local/python3 \
	&& python3 -V  

RUN /usr/local/python3/bin/pip3 install pymysql

转自 https://blog.csdn.net/u010473666/article/details/102559146

posted @ 2020-07-03 17:47  hanfe1  阅读(6749)  评论(0编辑  收藏  举报