[英]Docker error while running: no module named 'pytz'
When running docker-compose run server python manage.py makemigrations
(making migrations) and getting this error:运行
docker-compose run server python manage.py makemigrations
(进行迁移)并收到此错误:
django.template.library.InvalidTemplateLibrary: Invalid template library specified.
ImportError raised when trying to load 'rest_framework.templatetags.rest_framework': No mo
dule named 'pytz'
My docker-compose.yml
:我的
docker-compose.yml
:
version: '3'
services:
db:
build: ./etc/docker/db
restart: always
volumes:
- ./var/volumes/dbdata:/var/lib/mysql
env_file:
- ./etc/docker/db/env
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=example
interval: 1s
timeout: 5s
retries: 10
server: &web
build:
context: .
dockerfile: ./etc/docker/web/Dockerfile
volumes:
- ./server:/home/web/server
# depends_on:
# db: {condition: service_healthy}
ports:
- "8080:8080"
command: ["python", "manage.py", "runserver", "0.0.0.0:8080"]
I tried installing pytz
through pip install pytz, but I still get the same error.我尝试通过 pip install pytz 安装
pytz
,但我仍然得到同样的错误。 Now I'm confused, please explain what the problem could be.现在我很困惑,请解释问题可能是什么。
You need to install all dependencies inside Dockerfile.您需要在 Dockerfile 中安装所有依赖项。 Your dockerfile should contains something like
您的 dockerfile 应该包含类似
COPY requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
Where your requirements.txt contains all libraries you need to run the server.您的 requirements.txt 包含运行服务器所需的所有库。
or you can just install libs you need inside dockerfile或者你可以在 dockerfile 中安装你需要的库
RUN pip install pytz django etc...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.