Python module not found with docker

36 Views Asked by At

I try to bring a Python code into a docker image. For this I build:

FROM python:3.10-alpine
RUN apk update && apk upgrade
RUN pip install -U pip poetry==1.1.13
WORKDIR /app
COPY ./copilot-prototype .
RUN poetry export --without-hashes --format=requirements.txt > requirements.txt
RUN pip install -r requirements.txt

CMD [ "python", "/app/src/test_copilot/main.py" ]

My files are:

config.yaml
poetry.lock
pyproject.toml
README.md
requirements.txt
src/test_copilot/main.py
src/test_copilot/__init__.py
....

but everytime I get the message:

Traceback (most recent call last):
  File "/app/src/test_copilot/main.py", line 3, in <module>
    import test_copilot.gpt.api as api
ModuleNotFoundError: No module named 'test_copilot'

Why the module is not recognized inside the docker container on execute? From what I read the pip install will install exact this module?

0

There are 0 best solutions below