Package Question - please help.
A. Keyton Weissinger
keyton at weissinger.org
Fri Dec 14 21:56:40 EST 2001
I'm having a (possibly newbie) package import problem.
I have (on a Win2K box) the following dir setup:
c:\package1
\__init__.py
\subpackage1
\__init__.py
\myCode.py
\subpackage2
\__init__.py
\testMyCode.py
testMyCode.py is a unit test for myCode.py. It attempts to load a class from
within myCode.py with something like the following:
from package1.subpackage1.myCode import MyClass
I've added c:\package1 to the path (by adding it in the registy -- is there
an easier way?).
If I attempt to run testMyCode.py from within subpackage2, it dies and gives
me:
Traceback (most recent call last):
File "testMyCode.py", line 3, in ?
from package1.subpackage1.myCode import MyClass
ImportError: No module named package1.subpackage1.myCode
BUT, if I move that file to the root (c:\) and run it from there, it runs
like a champ.
>From the docs, I think I am doing it right (there is a __init__.py file
where it needs to be, I'm using the right syntax, etc). So why is this not
working???!?!?!
Thank you in advance.
Keyton
More information about the Python-list
mailing list