I'm getting some weird behavior regarding modules....
# ask-community
j
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:
Copy code
from projects.example.flows.hello_world
from projects import Config
But when I run the same import from Prefect, I get the following error:
Copy code
pipenv run prefect run -m projects.example.flows.hello_world                    
No module named 'projects'
a
Check out this Discourse topic for explanation of the issue and some ways you can solve it
🙌 1
k
Is that projects pip installed? You need it to be to use
-m
j
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
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
Yeah, that sounds good