0

The following is my folder structure:

/experiments
    /experiment_1
    /experiment_2
    /experiment_3
        /src
           /sample.py
helper.py

All experiments share some code, which I have exported into helper.py. Now I'm trying to import a function from helper.py into sample.py:

from ...helper import my_function

and I get the following error:

ImportError: attempted relative import with no known parent package

Please note that I have tried many solutions offered here, but none worked.

2 Answers2

1

create a __init__.py file in your parent folder.

Rama
  • 69
  • 2
1

The above question is related to

Importing files from different folder

The solution is to add the following lines in the sample.py:

import sys
sys.path.insert(1, 'path-to-experiments')

from helper import get_json