To add registration to django-project, I decided to use 'djoser' library. But while making migrations with
docker-compose run server python manage.py makemigrations
, the same error raises:
Creating school-co_server_run ... done
Traceback (most recent call last):
File "/home/web/server/manage.py", line 22, in <module>
main()
File "/home/web/server/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/web/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/web/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/home/web/venv/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/web/venv/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/web/venv/lib/python3.9/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'djoser'
ERROR: 1
The thing is that I already pip installed djoser (using the newest update of pip), I froze djoser too with the help of requirements.txt:
asgiref==3.2.10
attrs==21.2.0
Django==3.1
django-environ==0.8.1
django-extensions==3.1.5
django-filter==21.1
djangorestframework==3.12.4
djangorestframework-camel-case==1.2.0
drf-spectacular==0.21.0
inflection==0.5.1
jsonschema==4.2.1
Markdown==3.3.6
mysqlclient==2.1.0
Pillow==8.4.0
pyrsistent==0.18.0
pytz==2021.3
PyYAML==6.0
sqlparse==0.4.2
uritemplate==4.1.1
djoser==2.0.1
pandas=1.1.3
But it still doesn't work. Section of 'settings.py' INSTALLED_APPS also is correct:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base',
'school_co',
'django_extensions',
'rest_framework',
'rest_framework.authtoken',
'drf_spectacular',
'djoser',
'rest_framework_simplejwt',
]
I use docker-compose, and here is the web/Dockerfile
in which the operation happens:
FROM python:3.9-slim-bullseye
ENV PYTHONUNBUFFERED=1
RUN set -ex \
&& apt-get update \
&& apt-get install curl default-libmysqlclient-dev gcc -y \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash --home /home/web web
USER web
WORKDIR /home/web
COPY etc/requirements.txt ./etc/requirements.txt
RUN set -ex \
&& python -m venv /home/web/venv \
&& ./venv/bin/pip install --upgrade pip \
&& ./venv/bin/pip install --no-cache-dir -r ./etc/requirements.txt
COPY etc/env ./etc/env
ENV VIRTUAL_ENV /home/web/venv
ENV PATH /home/web/venv/bin:$PATH
WORKDIR /home/web/server
Seems that 'djoser' doesn't work without 'pandas'.
That is why it is needed to add this library too. My mistake was that I accidentally typed '=' instead of '==' in requirments.txt
.