Hello! Was wondering if anyone could help with thi...
# prefect-ui
d
Hello! Was wondering if anyone could help with this error whenever I run the flow on Prefect UI? Failed to load and execute Flow's environment: ModuleNotFoundError("No module named '/Users/david'") It looks like the error is coming from my local variable, PYTHONPATH, which is the path to the repo of custom libraries.
k
Hi @David Koo, when you register a Flow, Prefect saves it in Storage. When you run it, the Flow is loaded from the Storage and then executed. This way, Prefect does not see any of your code of data. The default is LocalStorage. This error happens when you use the default Local Storage, but then run the Flow on an agent without that Flow file. This can be another machine or maybe a container that doesn’t have the path. The Flow file needs to be pullable by the Agent. If you have different machines for registration and running, you need the file to be available on the machine running the Flow. You can use S3 Storage or Git Storage so that it’s accessible
This page may help you
d
@Kevin Kho Thank you so much for your help. This makes a lot more sense.
b
Hi @Kevin Kho I work with David. This flow is using Git storage, so I expect the flow itself is pulled down. I think the issue is that it uses custom python modules that we’ve written which are not installed on the machine that is pulling the main flow script. The pattern we’re trying to implement is that devs will create a sandbox project in prefect when they’re working on a flow, and they can register the flow from their branch to their sandbox project to test it. In this case, to be able to register the flow we had to
export PYTHONPATH=…
to get prefect register to work (it needs to be able to load our custom python modules)
k
Ah I see. What type of agent are you using?