为什么 Docker build 很难找到这么多 Python 模块?
Why does Docker build struggle to locate so many Python modules?
我在 docker 构建过程中不断看到一条错误消息,在 docker 尝试安装我的 requirements.txt 文件的部分显示 Module Not Found
。但是,它说找不到的模块版本有一半在可用版本列表中。
我一直在尝试旧版本,最终我会找到一个可用的版本,但同样的事情会发生在下一个包上。尝试构建一个肯定不正确的容器需要数小时。我假设这可能与包可能不会在容器的不同层之间传递有关,但我是 Docker 的新手所以无法判断这是否是问题或如何解决它。
我正在使用 WSL2 (Ubuntu 20.04) 在 Python 中构建一个烧瓶应用程序(从技术上讲,它是一个 Plotly Dash 应用程序,但我读过它与烧瓶一样工作)。我有一台 Windows 10 机器,我确保 Docker 设置为与 WSL2 和 Ubuntu 兼容。我在下面粘贴了一些错误,以及我当前的 requirements.txt、Docker 文件和文件结构。
我想知道如何防止此消息不断出现以及如何知道哪个软件包与 Docker 兼容?任何帮助将不胜感激。
我看到的一些错误消息是:
ERROR: Could not find a version that satisfies the requirement pandas==1.0.5 (from versions: 0.1, 0.2, 0.3.0, 0.4.0,
0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1,
0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1,
0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1,
0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3,
1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5)
#12 50.80 ERROR: No matching distribution found for pandas==1.0.5
或者:
#12 17.32 ERROR: Could not find a version that satisfies the requirement pandas==1.3.3 (from versions: 0.1, 0.2, 0.3.0,
0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0,
0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0,
0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0,
0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3,
1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5)
或者:
#12 108.3 ERROR: Could not find a version that satisfies the requirement numpy==1.18.5 (from versions: 1.3.0, 1.4.1,
1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2,
1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3,
1.14.0rc1, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0rc1, 1.15.0rc2, 1.15.0, 1.15.1, 1.15.2, 1.15.3,
1.15.4, 1.16.0rc1, 1.16.0rc2, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0rc1, 1.17.0rc2, 1.17.0,
1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0rc1, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0rc1,
1.19.0rc2, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5)
#12 108.3 ERROR: No matching distribution found for numpy==1.18.5
当前 requirements.txt 在回滚了一些包之后,但仍然没有找到一些模块:
Brotli==1.0.9
dash==2.0.0
dash-bootstrap-components==0.13.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
Flask==2.0.1
Flask-Compress==1.10.1
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==1.1.1
numpy==1.17.2
pandas==1.0.5
plotly==5.3.1
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
tenacity==8.0.1
Werkzeug==2.0.2
Docker文件:
ARG APP_IMAGE=python:3.6.1-alpine
FROM $APP_IMAGE AS base
FROM base as builder
##test these out
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
# RUN pip install flask==2.0.0 ###I've tried running pip install of the packages here, which worked but I still kept hitting the same error for each package
# RUN pip install MarkupSafe==2.0.1
RUN pip install --upgrade pip
RUN python3 -m pip install -r /requirements.txt
FROM base
ENV FLASK_APP index.py
WORKDIR /project
COPY --from=builder /install /usr/local
ADD . /project
ENTRYPOINT ["python3", "flask", "run", "--host=0.0.0.0"]
文件结构:
-apps
-main.py
-assets
-env
-app.py
-data.csv
-Dockerfile
-index.py #entry point to the application
-requirements.txt
尝试使用另一个 python 实例(这是 python 版本问题,python 3.6 不符合此要求)
我认为python3.8会满足这个要求
Docker 图像的 Alpine 版本是您尝试使用的软件的最紧凑图像。这是一个 Docker 图像,没有几个 Linux 包所依赖的库和模块。
如果您担心 Docker 图片的大小并且有存储要求,请尝试使用 Python 超薄图片。它比标准版本小,但包含几个 Alpine 没有的依赖项。
我在 docker 构建过程中不断看到一条错误消息,在 docker 尝试安装我的 requirements.txt 文件的部分显示 Module Not Found
。但是,它说找不到的模块版本有一半在可用版本列表中。
我一直在尝试旧版本,最终我会找到一个可用的版本,但同样的事情会发生在下一个包上。尝试构建一个肯定不正确的容器需要数小时。我假设这可能与包可能不会在容器的不同层之间传递有关,但我是 Docker 的新手所以无法判断这是否是问题或如何解决它。
我正在使用 WSL2 (Ubuntu 20.04) 在 Python 中构建一个烧瓶应用程序(从技术上讲,它是一个 Plotly Dash 应用程序,但我读过它与烧瓶一样工作)。我有一台 Windows 10 机器,我确保 Docker 设置为与 WSL2 和 Ubuntu 兼容。我在下面粘贴了一些错误,以及我当前的 requirements.txt、Docker 文件和文件结构。
我想知道如何防止此消息不断出现以及如何知道哪个软件包与 Docker 兼容?任何帮助将不胜感激。
我看到的一些错误消息是:
ERROR: Could not find a version that satisfies the requirement pandas==1.0.5 (from versions: 0.1, 0.2, 0.3.0, 0.4.0,
0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1,
0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1,
0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1,
0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3,
1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5)
#12 50.80 ERROR: No matching distribution found for pandas==1.0.5
或者:
#12 17.32 ERROR: Could not find a version that satisfies the requirement pandas==1.3.3 (from versions: 0.1, 0.2, 0.3.0,
0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0,
0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0,
0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0,
0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3,
1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5)
或者:
#12 108.3 ERROR: Could not find a version that satisfies the requirement numpy==1.18.5 (from versions: 1.3.0, 1.4.1,
1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2,
1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3,
1.14.0rc1, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0rc1, 1.15.0rc2, 1.15.0, 1.15.1, 1.15.2, 1.15.3,
1.15.4, 1.16.0rc1, 1.16.0rc2, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0rc1, 1.17.0rc2, 1.17.0,
1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0rc1, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0rc1,
1.19.0rc2, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5)
#12 108.3 ERROR: No matching distribution found for numpy==1.18.5
当前 requirements.txt 在回滚了一些包之后,但仍然没有找到一些模块:
Brotli==1.0.9
dash==2.0.0
dash-bootstrap-components==0.13.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
Flask==2.0.1
Flask-Compress==1.10.1
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==1.1.1
numpy==1.17.2
pandas==1.0.5
plotly==5.3.1
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
tenacity==8.0.1
Werkzeug==2.0.2
Docker文件:
ARG APP_IMAGE=python:3.6.1-alpine
FROM $APP_IMAGE AS base
FROM base as builder
##test these out
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
# RUN pip install flask==2.0.0 ###I've tried running pip install of the packages here, which worked but I still kept hitting the same error for each package
# RUN pip install MarkupSafe==2.0.1
RUN pip install --upgrade pip
RUN python3 -m pip install -r /requirements.txt
FROM base
ENV FLASK_APP index.py
WORKDIR /project
COPY --from=builder /install /usr/local
ADD . /project
ENTRYPOINT ["python3", "flask", "run", "--host=0.0.0.0"]
文件结构:
-apps
-main.py
-assets
-env
-app.py
-data.csv
-Dockerfile
-index.py #entry point to the application
-requirements.txt
尝试使用另一个 python 实例(这是 python 版本问题,python 3.6 不符合此要求)
我认为python3.8会满足这个要求
Docker 图像的 Alpine 版本是您尝试使用的软件的最紧凑图像。这是一个 Docker 图像,没有几个 Linux 包所依赖的库和模块。
如果您担心 Docker 图片的大小并且有存储要求,请尝试使用 Python 超薄图片。它比标准版本小,但包含几个 Alpine 没有的依赖项。