1

I am working on a python app using VS Code. I work with the following structure:

my_app
├── venv
├── my_app
│   ├── __init__.py
│   ├── main.py
│   ├── module_1
│   │   ├── __init__.py
│   │   ├── functionality_1.py
│   │   └── functionality_2.py
│   ├── module_2
│   │   ├── __init__.py
│   │   └── functionality_3.py
│   └── ...

When I try to run the main.py I get a ModuleNotFoundError. I can see that the path where the terminal is starting from is the top my_app directory. If I use cd to go one level lower to the bottom my_app directory, I am able to run the script without error.

Even though I have a workaround, this is not ideal. For example, the debugger also starts from the top my_app directory and I did not find a workaround for that.

I can also open the bottom my_app folder in VS code. The issue then becomes that the virtual environment that I have created is one level higher and VS code does not find it.

Is there something I am doing wrong in the structuring of my app? Or am I missing something else?

1 Answer 1

1

I figured it out. The top folder and package folder (my_app) should be named exactly the same.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.