https://prefect.io logo
Title
j

Jason

04/20/2022, 2:55 PM
I'm getting some weird behavior regarding modules. I can correctly import my flow and the Config class from
projects
from both Python and Jupyter Notebook:
from projects.example.flows.hello_world
from projects import Config
But when I run the same import from Prefect, I get the following error:
pipenv run prefect run -m projects.example.flows.hello_world                    
No module named 'projects'
a

Anna Geller

04/20/2022, 2:58 PM
Check out this Discourse topic for explanation of the issue and some ways you can solve it
🙌 1
k

Kevin Kho

04/20/2022, 2:58 PM
Is that projects pip installed? You need it to be to use
-m
j

Jason

04/20/2022, 3:02 PM
Yup - so when I use pipenv run prefect run -p dir/dir/file.py I also get:
ModuleNotFoundError: No module named 'projects'
. It's just weird because usually I don't need to bother with a setup.py. As long as the directory is modularized with an init.py I can usually import.
k

Kevin Kho

04/20/2022, 3:03 PM
That is to import and use in a script, which can work if the relative path is right but it won’t work in all paths. I think the execution path of the
prefect run
might be different. You do need the
setup.py
to get that working. You know how to do that?
j

Jason

04/20/2022, 3:03 PM
Yeah, that sounds good