0

I have the same problem as expressed here (none of the solutions worked for me). I'll rephrase and tell you exactly where I am.

My folder structure is:

Mar29
     utils.py
     Subfolder
         running.py

Currently, I'm in the directory Mar29/Subfolder, and in the file running.py, I want to import all functions from utils.py.

Here's what I've tried at the top of running.py:

from .. import utils
from . import utils
from ../ import utils
import utils
from utils import *

The most common error I'm getting is:

ValueError: Attempted relative import in non-package

How can I import all functions from the utils.py file?

EDIT: also tried

from ..utils import *
from ../utils.py import *
from ../utils import *

Often got an invalid syntax error.

StatsSorceress
  • 3,019
  • 7
  • 41
  • 82

1 Answers1

0

The parent directory of the package is not being included in sys.path for security reasons. So add it to the path manually:

import sys
sys.path.insert(0,'..')

import utils
pastaleg
  • 1,782
  • 2
  • 17
  • 23