pythonimportpython-venv

Problem with importing Python module in VsCode


I'm learning Python and wanted to make a snack store management application. When I try to import authenticate logic, it shows the following error:

Traceback (most recent call last): File "/Users/mac/Dev/Learn_python/btl/snack_app/source_code/views/login_screen.py", line 5, in <module>
import source_code.controllers.authenticate as auth 
ModuleNotFoundError: No module named 'source_code'

My import code looks like this: import controllers.authenticate as auth

I use Venv and in the image is the structure of the project The code structure

I think vscode confirmed the module exists because it shows green in the code like this VSCode confirm

I don't know what's wrong.

I tried adding source_code.controllers and the error became ModuleNotFoundError: No module named 'source_code'.

I activated Venv (If that matters).


Solution

  • Somehow this problem comes from my VScode or my computer. I downloaded Pycharm and no problem since.