【发布时间】:2022-07-19 14:21:02
【问题描述】:
我正在构建一个 docker 映像。在其中,我试图在一个RUN 中安装许多 python 包。该命令中的所有软件包都已正确安装,但 PyInstaller 不是出于某种原因,尽管构建日志让我认为它应该是:Successfully installed PyInstaller
重现问题的最小 Dockerfile:
FROM debian:buster
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
unixodbc-dev
RUN python3 -m pip install --no-cache-dir pyodbc==4.0.30 && \
python3 -m pip install --no-cache-dir Cython==0.29.19 && \
python3 -m pip install --no-cache-dir PyInstaller==3.5 && \
python3 -m pip install --no-cache-dir selenium==3.141.0 && \
python3 -m pip install --no-cache-dir bs4==0.0.1
RUN python3 -m PyInstaller
最后一个运行命令失败并显示/usr/bin/python3: No module named PyInstaller,所有其他包都可以按预期导入。
这个问题也可以通过这个 Dockerfile 重现:
FROM debian:buster
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip
RUN python3 -m pip install --no-cache-dir PyInstaller==3.5
RUN python3.7 -m PyInstaller
这个问题的原因是什么?解决方法是什么?
【问题讨论】:
标签: python docker pip pyinstaller