0

I have the following file structure:

configs.py
__init__.py
(folder) /scritps
             load.py

I need to import in load.py a series of config values from configs.py

In __init__.py I have this

#!/usr/bin/python
# -*- coding: utf-8 -*
__all__= ["configs"]

in load.py I import the file with this:

from .. import configs

but I always get this error:

from .. import configs
ValueError: Attempted relative import in non-package

I've also tried import the file using:

from ..configs import *

but I get the same error.

What I'm doing wrong? I'm using python 2.6

Karlovalentin
  • 321
  • 1
  • 3
  • 14
  • `load.py` is not part of a package. The `from .. import` syntax is for package-internal relative imports. Since your file isn't part of a package in the first place, you get the error you see. – Sven Marnach Jan 19 '15 at 19:30
  • possible duplicate of [How to do relative imports in Python?](http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python) – cmidi Jan 19 '15 at 19:38

1 Answers1

0

I would suggest you ensure your folder is in your PYTHONPATH. http://users-cs.au.dk/chili/PBI/pythonpath.html

Ryan O'Donnell
  • 617
  • 6
  • 14