如何在已安装 Python 3.4 的 Docker 容器中升级到 Python 3.5? (我是 运行 Docker 容器 Ubuntu 20.04)

How to upgrade to Python 3.5 in a Docker container that has already installed Python 3.4? (I'm running Docker containers on Ubuntu 20.04)

我在 Ubuntu 20.04 上使用 Docker。 Docker 容器已经安装了 Python 3.4.2。 现在,我要 将其升级到 Python 3.5 或更高版本。我没有在网上找到任何有用的东西来做到这一点。如果有人伸出援手,将不胜感激。

我需要它来在 Docker 容器上安装 numpy。我已经为 Python 3.4.2 升级了 pipsetuptools,但是当我 运行:

pip3 安装 numpy

它 returns 需要 Python 3.5 或更高版本。

如有任何帮助,我们将不胜感激!

更改 Dockerfile 中的基础映像,以使用新的 Python 版本,然后重建映像。

如@Raedwald 所述,您可以使用 ucmercedandeslab/tinyos_debian 图像作为基础图像并创建一个新的 docker 图像并安装指定版本的 python。为此,您需要执行以下操作:

步骤 1:创建 Dockerfile。您可以使用文件指定的 here. This Dockerfile uses the pyenv 库来管理 python 版本。您需要做的就是将第一行从

FROM debian:stableFROM ucmercedandeslab/tinyos_debian:latest

将 python arg (ARG PYTHON_VERSION=3.6.2) 更改为您喜欢的任何版本。默认为 Python 3.6.2

步骤 2:通过 docker build 命令构建 docker 图像

您现在有一个 docker 图像,默认 python 3.6.2 python。