当我尝试构建图像时:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
这是我的 dockerfile:
FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
RUN pip install python3-wkhtmltopdf
RUN apt-get update
RUN apt-get install -y wkhtmltopdf
COPY . .
CMD [ "python3", "app.py"]
我在这里遗漏了什么?
答案 0 :(得分:0)
看起来您实际上是在尝试安装 py3-wkhtmltopdf。为此,您只需利用 python -m pip
并直接安装软件包:
FROM python:3.8-slim-buster
WORKDIR /app
# following their linux installation instructions
RUN apt-get update && apt-get install -y \
xvfb \
xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic \
wkhtmltopdf
COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt
COPY . .
CMD [ "python", "app.py"]
其中 requirements.txt
可能看起来像:
py3-wkhtmltopdf