patternpythonCriticalCanonical
Importing modules from parent folder
Viewed 0 times
fromimportingparentfoldermodules
Problem
I am running Python 2.5.
This is my folder tree:
(I also have
How do I import the
Note: The main module being run is in the
This is my folder tree:
ptdraft/
nib.py
simulations/
life/
life.py(I also have
__init__.py in each folder, omitted here for readability)How do I import the
nib module from inside the life module? I am hoping it is possible to do without tinkering with sys.path.Note: The main module being run is in the
ptdraft folder.Solution
It seems that the problem is not related to the module being in a parent directory or anything like that.
You need to add the directory that contains
You said that
You need to add the directory that contains
ptdraft to PYTHONPATHYou said that
import nib worked with you, that probably means that you added ptdraft itself (not its parent) to PYTHONPATH.Context
Stack Overflow Q#714063, score: 157
Revisions (0)
No revisions yet.