1

I've been searching on stackoverflow and can't find out what's wrong.

My directory structure is as follows:

--project
  --__init__.py
  --helpers
    --__init__.py
    --functions.py
  --set1
    --__init__.py
    --foo.py
  --set2
    --__init__.py
  --setn
    --__init__.py

In foo.py I want to import functions.py I do this with

from ..helpers import functions

And this is giving me the error:

Attempted relative import in non-package error

All of the answers I've found so far deal with setting up init.py properly.

Using python2.7 on Mac

user2886057
  • 646
  • 1
  • 5
  • 15
  • Possible duplicate of http://stackoverflow.com/questions/11536764/how-to-fix-attempted-relative-import-in-non-package-even-with-init-py – YellowShark Jan 03 '17 at 18:30

1 Answers1

0

You need to use from project.helpers import functions, you're not actually using your script as a package. See her for more info: How to fix "Attempted relative import in non-package" even with __init__.py

Community
  • 1
  • 1
YellowShark
  • 2,169
  • 17
  • 17