import own module #62
-
Hi, I am trying to import and execute a self-written module using markdown-exec. It works perfectly well if example.py is restricted to standard packages but runs into ModuleNotFoundError errors when trying to import a self-written module. I have tried different specifications without success. Any advise is highly appreciated. Below the set-up: I am using Python 3.8 with the following repository
with example.md:
and example.py:
and module.py:
with mkdocs.yml:
Kind regards and many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi! You shouldn't try to import from If your project is installed in the current venv (whatever the layout it uses), you should be able to import with Let me know if that helps 🙂 |
Beta Was this translation helpful? Give feedback.
-
Hi, Installing the project in the current venv indeed resolved the issue. I initially assumed that would not be necessary, but I also had no idea about the src layout vs flat layout philosophy. I have learned a lot reading the discussions about it. Thank you very much for pointing me in that direction and for the quick response in general. Very much appreciated! |
Beta Was this translation helpful? Give feedback.
Hi!
You shouldn't try to import from
src
. Please see docs for the flat vs. src layouts here: https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/.If your project is installed in the current venv (whatever the layout it uses), you should be able to import with
from module import func
.Let me know if that helps 🙂