2

This is my file structure: enter image description here

I am trying to get a function (getFreq()) out of the utils.py file.

However, when doing this in the part1.py file:

from ..utils.utils import getFreq

print(getFreq(["R8","U5","L5","D3"]))

It just says: ImportError: attempted relative import with no known parent package.

How would I fix this and import it?

Note: the __init__.py file is empty in the utils folder to make Python think it is a module (What I have been told to do on Google).

7
  • Does the parent directory of day3 (presumably 2021) have an __init__.py, so it is considered as a Python module? Commented Dec 5, 2021 at 18:03
  • Think so - at least that is what google have said :) Commented Dec 5, 2021 at 18:04
  • When I look at your screenshot I am under the impression that there is only a .gitignore but no __init__.py inside the 2021 directory. Commented Dec 5, 2021 at 18:05
  • Hmm, will that fix it? Commented Dec 5, 2021 at 18:05
  • No, it doesn't fix it... Commented Dec 5, 2021 at 18:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.