python import error, what's wrong?

S

smith jack

I am using pydev plugin in eclipse, all things works just as well
but now i have confronted with a confusing problem, that is i can
import a module write by myself successfully, but when i try to run
this program,
error just shows up, what's wrong?

the directory structure is as follows:

src
org.test
A.py
org.lab
B.py


contents of A seems like:
class A
...

contents of B seems like: // I try to run B.py,
python import error just appears, why?

from org.test.A import A
a = A()
 
U

Ulrich Eckhardt

smith said:
I am using pydev plugin in eclipse, all things works just as well
but now i have confronted with a confusing problem, that is i can
import a module write by myself successfully, but when i try to run
this program,
error just shows up, what's wrong?

the directory structure is as follows:

src
org.test
A.py
org.lab
B.py

Python uses a dot as separator between different parts of nested structures,
like e.g. the directories during import. I guess your directory naming
conflicts with that. Try this structure instead:

src
org
test
A.py
lab
B.py

or maybe

src
org_test
A.py
org_lab
B.py

contents of A seems like:
class A
...

contents of B seems like: // I try to run B.py,
python import error just appears, why?

"just appears" is not a sufficient discription of an error. I'd suggest
reading Eric S. Raymond's excellent essay on "Asking Smart Questions", it
will avoid such mistakes.

Uli
 

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

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top