Import problem
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Mar 6 09:48:24 EST 2010
On Sat, 06 Mar 2010 03:53:53 -0800, Johny wrote:
>>>> import sys
>>>> sys.path.append('C:\\A')
>>>> from A.B import bmodule
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named A.B
The current directory is irrelevant, except that it is automatically
added to the PYTHONPATH. That's why you can import A.B when the current
directory is C.
You are trying to import module B from package A *inside* directory C:\A,
but there is no such package A inside C:\A. You need to add C to the
path, and then it should work.
--
Steven
More information about the Python-list
mailing list