1

Possible Duplicate:
How to do relative imports in Python?

How do I import from a higher level directory in python.

For example:

I have project/lib/lib.py project/stuff/main.py

i want to import lib.py in main.py

Thanks in advance

Community
  • 1
  • 1
Jared
  • 11
  • 1
  • 2

2 Answers2

3

You can do it like:

from ..lib import lib
Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222
0

standard method is to add project to your path and do

import lib.lib

You will need a file called __init__.py in the lib folder as well, which can be blank.

Will
  • 4,498
  • 1
  • 21
  • 20