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

2

You can do it like:

from ..lib import lib
Klaus Byskov Pedersen
  • 111,411
  • 28
  • 180
  • 220
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,377
  • 1
  • 20
  • 20