Home > Back-end >  Docker Anaconda ModuleNotFoundError
Docker Anaconda ModuleNotFoundError

Time:01-31

I am on Linux (Ubuntu) running a docker container that looks like

FROM continuumio/miniconda

COPY . /root_dir/

WORKDIR root_dir

RUN ["conda", "env", "create", "-f", "environment.yaml"]

ENV PYTHONPATH=/rootdir/src

CMD ["conda", "run", "-n", "kardia_env", "python", "run/entrypoint.py"]

The container builds fine and resolves the environment, however I get the error ModuleNotFoundError: No module named 'foo' when I run it; run/entrypoint.py tries to import foo

I do not understand since foo is a subdirectory of src with an __init__.py file, and the PYTHONPATH has been updated to include src. Can anyone shed some light on to this error?

CodePudding user response:

  1. You are mispelling the root_dir folder name in your PYTHONPATH. This should fix the issue.

Change this:

ENV PYTHONPATH=/rootdir/src

To this:

ENV PYTHONPATH=/root_dir/src
  •  Tags:  
  • Related