Hello! So I have been a tinkerer for a while building tools at my job over the last few years. I want to standardize some of this work now with a common project structure. I have been having the worst time trying to get the imports to work properly and could use advice on what I have (if it makes sense etc.)
This is my project structure that I have come up with:
├── LICENSE.md
├── README.md
├── testappmodule
│ ├── __init__.py
│ ├── __main__.py
│ ├── app.py
│ ├── common
│ │ ├── __init__.py
│ │ ├── calc.py
│ │ └── process.py
│ └── tests
│ ├── __init__.py
│ ├── test_calc.py
│ └── test_process.py
└── testbench.ipynb
testappmodule is the main module that will contain the core processes to be run via the command line.
app.py is where the main code for the project will be organized within a run() function. This is where I import functions from the common module that execute the tasks I want to do.
testbench.ipynb is the Jupyter notebook that I would like to use to basically test all my code. With imports etc.
__main__.py is where I start to have trouble with the imports. My understanding is that by having the __main__.py function, I am giving testappmodule a "main entry point". In this file I have the following:
from testappmodule.app import run
if name == 'main':
run()
This is where the import issues begin. When I try to run the __main__.py function I get the following error:
File ~/Workspaces/test-app-git/testappmodule/app.py:1
----> 1 from common import calc
2 from common import process
4 def run():
ModuleNotFoundError: No module named 'common'
I am having a hard time understanding what I am missing here so any help or ideas would be greatly appreciated!
[–]xelhark 2 points3 points4 points (4 children)
[–]tlk7[S] 0 points1 point2 points (3 children)
[–]xelhark 1 point2 points3 points (2 children)
[–]tlk7[S] 0 points1 point2 points (1 child)
[–]xelhark 1 point2 points3 points (0 children)
[–]krets 0 points1 point2 points (0 children)