您好,我正在关注本教程链接。一切工作正常,但当我运行以下命令时,它说未找到枕头,但枕头已安装。
docker-compose -f docker-compose.prod.yml exec app python manage.py migrate --noinput
这是错误:
employee.Employee.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
students.Student.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
然后我再次尝试使用以下命令安装
docker-compose -f docker-compose.prod.yml exec app python -m pip install Pillow
它说枕头是 枕头已安装
Requirement already satisfied: Pillow in /usr/local/lib/python3.8/site-packages (6.2.1)
这是我的 docker 文件
###########
# BUILDER #
###########
# pull official base image
FROM python:3.8.3-alpine as builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev zlib-dev jpeg-dev musl-dev
# lint
RUN pip install --upgrade pip
RUN pip install Pillow
COPY . .
# install dependencies
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
#########
# FINAL #
#########
# pull official base image
FROM python:3.8.3-alpine
# create directory for the app user
RUN mkdir -p /home/app
# create the app user
RUN addgroup -S app && adduser -S app -G app
# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/mediafiles
WORKDIR $APP_HOME
# install dependencies
RUN apk update && apk add libpq
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --no-cache /wheels/*
白衣非少年
青春有我
幕布斯6054654
相关分类