1
Vote

Importing module using relative path

description

Hi! I'm new to PTVS. I just noticed that the intellisense doesn't work unless I type the project name first followed by the folder name, then followed by the python file.

I have a project with several folders. Inside the folders are python files. The structure is like this:
projName
   folder1
      module1.py
      module2.py
   folder2
      module3.py
Inside module1, I need to import module3. When I type
from projName.folder2.module3 import something
it works. But it doesn't work when I start with relative path like this
from folder2.module3 import something
What should I do in order for me to import modules without specifying the project name first? so that non-PTVS users can also use my code (because it only uses relative paths).

comments

pminaev wrote Jan 2 at 8:36 PM

Do you have __init__.py in folder1 and folder2? They won't be treated as packages if that is not the case.