简体   繁体   中英

Pip not found error when installing wkhtmltopdf while building Docker image

When I try to build the image I get:

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'

This is my 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"]

What am I missing here?

It looks like you are actually trying to install py3-wkhtmltopdf . To do this, you can just leverage python -m pip and install the package directly:

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"]

Where requirements.txt might look like:

py3-wkhtmltopdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM