51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

python 安装 3.11(docker 镜像)

python 安装 3.11

参考

FROM centos:7.5.1804
MAINTAINER baimeidashu <baimeidashu@qq.com>

ENV PATH $PATH:/usr/local/python3/bin/ ENV PYTHONIOENCODING utf-8

RUN set -ex
# 替换yum源 && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \ && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \ # 安装python依赖库 && yum makecache
&& yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget
&& yum clean all
&& rm -rf /var/cache/yum
# 下载安装python3 && wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
&& mkdir -p /usr/local/python3
&& tar -zxvf Python-3.11.0.tgz
&& cd Python-3.11.0
&& ./configure --prefix=/usr/local/python3
&& make && make install && make clean
# 修改pip默认镜像源 && mkdir -p ~/.pip
&& echo '[global]' > ~/.pip/pip.conf
&& echo 'index-url = https://mirrors.aliyun.com/pypi/simple' >> ~/.pip/pip.conf
&& echo 'trusted-host = mirrors.aliyun.com' >> ~/.pip/pip.conf
&& echo 'timeout = 120' >> ~/.pip/pip.conf
# 更新pip && pip3 install --upgrade pip
# 安装wheel && pip3 install wheel
# 删除安装包 && cd ..
&& rm -rf /Python*
&& find / -name "*.py[co]" -exec rm '{}' ';'
# 设置系统时区 && rm -rf /etc/localtime
&& ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3.10 以上的有问题, 需要安装 openssl

参考: 解决Python3.10报错问题 SSLError("Can't connect to HTTPS URL because the SSL module is not available_python 3.10 ssl-CSDN博客

3.19.9 是没问题的:

Dockerfile

FROM centos:7.5.1804
#FROM registry.cn-hangzhou.aliyuncs.com/baimeidashu-k8s/ffmpegcentos79:v1.1
MAINTAINER zhaozhiyong  <715740383@qq.com>

ENV PATH $PATH:/usr/local/python3/bin/ ENV PYTHONIOENCODING utf-8

#ADD Python-3.11.0.tgz ./

RUN set -ex
# 替换yum源 && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \ && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \ # 安装python依赖库 && yum makecache
&& yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget
&& yum clean all
&& rm -rf /var/cache/yum
# 下载安装python3 && wget https://www.python.org/ftp/python/3.9.19/Python-3.9.19.tgz
&& mkdir -p /usr/local/python3
&& tar -zxvf Python-3.9.19.tgz
&& cd Python-3.9.19
&& ./configure --prefix=/usr/local/python3
&& make && make install && make clean
# 修改pip默认镜像源 && mkdir -p ~/.pip
&& echo '[global]' > ~/.pip/pip.conf
&& echo 'index-url = https://mirrors.aliyun.com/pypi/simple' >> ~/.pip/pip.conf
&& echo 'trusted-host = mirrors.aliyun.com' >> ~/.pip/pip.conf
&& echo 'timeout = 120' >> ~/.pip/pip.conf
# 更新pip && pip3 install --upgrade pip
# 安装wheel && pip3 install wheel
# 删除安装包 && cd ..
&& rm -rf /Python*
&& find / -name "*.py[co]" -exec rm '{}' ';'
# 设置系统时区 && rm -rf /etc/localtime

赞(8)
未经允许不得转载:工具盒子 » python 安装 3.11(docker 镜像)