0

I'm having this issue in python with relative imports, when I want to import a file from another folder I get an error.

File structure:

python/
  helpers/
    index.py
  posts/
    post.py

Then, I do in the posts/post.py file:

from ..helpers.index import conn

But when I run the python file, I get this error:

ImportError: attempted relative import with no known parent package

I don't really understand what I'm doing wrong. Especially that vscode understands that I'm trying to import this file

Thanks in advance

johannb75
  • 357
  • 5
  • 16

1 Answers1

0

I think this answer might be helpful: Relative imports for the billionth time

In the section titled "Relative imports".

Omri Shayo
  • 64
  • 8