Problems with import
Diez B. Roggisch
deets at nospam.web.de
Tue Dec 4 06:49:30 EST 2007
alexLIGO at googlemail.com wrote:
> Hi,
>
> I have some problems when importing a library. Suppose I have a
> directory /home/user/pythonlib/package in which I have a python-
> library called test.py. Now I want to import that, so I put the
> following directory into the PYTHONPATH: /home/user/pythonlib and in
> my main python script I put:
>
> from package import test.
>
> BUT I get an error:
>
> ImportError: cannot import name test
>
> So how can I test and check what is going on, why python does not find
> the library?
Do you have this directory structure?
package/__init__.py
test.py
Only then (with the __init__.py in place, it can be empty) package will be
recognized as such.
Diez
More information about the Python-list
mailing list