Problems with import

A

alexLIGO

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
 
D

Diez B. Roggisch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,302
Latest member
endevsols

Latest Threads

Top