Hy every one, I am using Docker storage for my flo...
# ask-community
s
Hy every one, I am using Docker storage for my flow and get this error
ModuleNotFoundError: No module named 'utils'
when running
python file.py
It seems like that my local package utils is not found during docker build. Here is the structure of my folder. 
Copy code
src
	utils/
	file.py
	__init__.py
I am using a custom docker image where I already copied every thing in src in the image. Please help me on this. Any help is appreciated 🙏Many thanks already
g
Looks similar to https://prefect-community.slack.com/archives/C014Z8DPDSR/p1627481668187900 , try adding a line to your Dockerfile which executes
pip install -e .
to install your package locally
s
hey @Greg Roche thx for the link. I am running the agent in a different machine. So I guess I have have to package this with Docker? what exactly does it mean?
g
The point is that the agent needs to be able to successfully run the
import utils.whatever
python commands which are at the top of your flow logic. If you're just running your agent on the other machine by starting a command line and running
prefect agent local start
or something, then installing your package locally with the editable flag before starting the agent should be enough (or better, create and activate a venv, install all dependencies, then
pip install -e .
, then start your agent from the venv). It's a bit cleaner if you run your agent from within a Docker container because then you can put all this setup in the Dockerfile and starting the agent is just as simple as running the container.
s
okay, thanks @Greg Roche, in my case I have a Kubernetes Agent so it will be a bit different but I think I got what you mean. Will come back after some works
k
Greg is right, I think the Python scripts need to be installed as module because the location where the script is running from might be different than you expect and the
pip install -e .
makes the library available to your agent whatever directory you’re in.
s
@Greg Roche and @Kevin Kho I’ve added a setup.py with the necessary metadata and then run the
pip install -e .
in my custom Dockerfile and it worked fine. Thanks for the help guys 🙏