0

Below is my file directory

.
├── README.md
├── func
│   ├── __init__.py
│   ├── main.py
│   └── requirements.txt
└── utils
    ├── __init__.py
    ├── abc.py
    └── def.py

abc.py

def test():
    return 'berjaya'

main.py

from ..utils import test  

when I run python main.py

get an error ImportError: attempted relative import with no known parent package

how to solve the issue?

In main.py i have tried a few ways

  1. from .utils import test
  2. from ..utils import test

All got the same error

zarzar
  • 1
  • 3
  • @SameerWaseem No, that's completely wrong, and a syntax error. – tripleee Feb 02 '23 at 11:50
  • The fundamental problem is that Python does not give you access to the file system. You can hack your way around that, but the proper solution is to create a package and install it. – tripleee Feb 02 '23 at 11:51

0 Answers0