Helios
Helios

Reputation: 715

Docker Anaconda ModuleNotFoundError

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?

Upvotes: 0

Views: 244

Answers (1)

Nuno Carvalho
Nuno Carvalho

Reputation: 177

  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

Upvotes: 1

Related Questions