Estoy ejecutando un proyecto Django en un contenedor Docker y quiero agregar un módulo (específicamente, django-prometheus )
Ejecuté: pip install django-prometheus y docker run -p 9090:9090 prom/prometheus con éxito, y realicé las modificaciones necesarias en mis archivos settings.py y urls.py , como se especifica en el LÉAME .
Luego reconstruí el proyecto y lo reinicié, pero me está dando el error ModuleNotFoundError: No module named 'django_prometheus'
(informe de error completo:
Traceback (most recent call last): api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker api_1 | worker.init_process() api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process api_1 | self.load_wsgi() api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi api_1 | self.wsgi = self.app.wsgi() api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi api_1 | self.callable = self.load() api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load api_1 | return self.load_wsgiapp() api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp api_1 | return util.import_app(self.app_uri) api_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app api_1 | __import__(module) api_1 | File "/usr/src/app/project/wsgi.py", line 16, in <module> api_1 | application = get_wsgi_application() api_1 | File "/usr/local/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application api_1 | django.setup(set_prefix=False) api_1 | File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup api_1 | apps.populate(settings.INSTALLED_APPS) api_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate api_1 | app_config = AppConfig.create(entry) api_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 90, in create api_1 | module = import_module(entry) api_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module api_1 | return _bootstrap._gcd_import(name[level:], package, level) api_1 | ModuleNotFoundError: No module named 'django_prometheus' api_1 | [2019-07-01 12:19:36 +0200] [16] [INFO] Worker exiting (pid: 16))
Antes de agregar este módulo, el proyecto funcionó perfectamente, ¿qué me estoy perdiendo?
En su Dockerfile, debe asegurarse de tener un comando de instalación de pip. Por favor, eche un vistazo al siguiente ejemplo. El módulo Prometheus debe aparecer en el archivo requirements.txt.
RUN apt-get update \ && apt-get install -y --no-install-recommends software-properties-common \ && apt-get update \ && apt-get install -q -y --no-install-recommends python3 python3-dev python3-pip python3-setuptools python3-wheel gcc \ && apt-get install -q -y vim \ && apt-get clean ADD requirements.txt /app/requirements.txt RUN pip3 install -r /app/requirements.txt # Add the application source code. ADD . /app