Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1K
Visualizações
Django: module not found while running in Docker container

I'm running a Django project in a Docker container, and I want to add a module (specifically, django-prometheus)

I ran: pip install django-prometheus and docker run -p 9090:9090 prom/prometheus successfully, and I made the necessary alterations to my settings.py and urls.py files, as specified in the README

I then rebuilt the project and restarted it, but it is giving me the error ModuleNotFoundError: No module named 'django_prometheus'

(full error report:

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)

)

Prior to me adding this module the project worked perfectly, what am I missing?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In your Dockerfile, you should make sure you have a pip install command. Please have a look at the following example. The prometheus module should be listed in the requirements.txt file.

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
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda