Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
docker python custom module not found

I am new to docker and trying to move one simple application to docker. Python standard modules I am able to import using "pip install". However, I have some custom python utility files that I would like to use. These files are in separate package "utils".

In my main python file : test.py, I am doing

from utils import math.py, logger.py

This outside of docker works fine, but when running through docker gives me the error "ImportError: No module named utils".

My Dockerfile code:

FROM python:2.7.11
ADD ./ test_project/
WORKDIR test_project
ENV PATH=$PATH:/test_project/utils
ENV PYTHONPATH /test_project/utils

CMD [ "python", "report/test.py"]

My directory structure:

  • test_project
    • report
    • utils

Any suggestions?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You set PYTHONPATH to /test_project/utils. When trying resolve the module utils, it is looking for one of:

  • file /test_project/utils/utils.py
  • directory /test_project/utils/utils/ that contains __init__.py.

It looks like you have this?

utils/math.py
utils/logger.py

I wonder if what you really mean to do is

# different path...
ENV PYTHONPATH /test_project

from utils import math
from utils import logger
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda