471,337 Members | 1,017 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Problems with import

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?
Thanks
Alex
Dec 4 '07 #1
1 1068
al******@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
Dec 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Katja Filippova | last post: by
1 post views Thread by Rolan | last post: by
1 post views Thread by Michael Yanowitz | last post: by
1 post views Thread by Mario Lacunza | last post: by
1 post views Thread by Andrew | last post: by
3 posts views Thread by scoots987 | last post: by
3 posts views Thread by John Dann | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.