Sorry if this a dumb question but i could not find similar question like this, Can someone help me understand the absolute import and how importing actually works in python, I watched a video where the instructor created two package one called package1 and package2, in the package2 this has a sub_package since am using python 3 i recreated the video topic and the above I placed an init file to some of the packages but not all because init is not really needed in the first place. I also have a root_file which is in the main directory of the overall project top level, this root_file module or script can access all the package, now when I import all the module via their package and sub-package into the root_file I have a function and name in the module to be printed out so when called from root_file.py I know who is who, this work fine, however, my issue is now when I try to absolute import from (package2 / module name = file2) into (package1 / module name = file1) I get a dirty big fat error
ModuleNotFoundError: No module named 'package2'
Traceback (most recent call last):
from package2 import file2
ModuleNotFoundError: No module named 'package2'
However, the import above worked for the instructor. also, the same error occurs when I even attempt the basic to import from same package1 file1 into package1 file 2 I get
Traceback (most recent call last):
File "/Users/ganiyu/Desktop/Python_import/package1/file1.py", line 2, in <module>
from package1.file2 import pkg_1_file_2_func
ModuleNotFoundError: No module named 'package1'
Why does it only work when I import call from the packages and module into root_File.py or can some try recreating my issue or give me my answer also i am lost on why python keeps saying that 'package2 ' or the i try with package one or sub_packed it says the packages are modules.
EDITED
I found out that vscode is the issue it work on pycharm very all import combination can someone assist me how to get this working on vscode because am lost.