0

Structure:

folder "a":
     __init__.py
     car.py
folder "b":
     tad.py

And I do in tad.py:

from a.car import *


ModuleNotFoundError: No module named 'a'

What can I do?? EDIT: I added init to the top level folder, and now throws this error:

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000031bc (most recent call first):
<no Python frame>
kukelia
  • 85
  • 1
  • 1
  • 10
  • Does this answer your question? [Importing files from different folder](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) – Schnitte Apr 20 '22 at 12:56
  • I want to resolve this with the classic importing syntax, not sys.path.insert – kukelia Apr 20 '22 at 12:59

1 Answers1

1

You should try

from .a.car import *

The leading dot goes one directory up in folder hierarchy.

Wasif
  • 14,755
  • 3
  • 14
  • 34