can't figure out error: module has no attribute...

C

Chris_147

but it seems to depend on from where I start the Python shell.

so I've got a module selfservicelabels.py with some variables defined,
like this:
BtnSave = "link=label.save"
DeliveryAutomaat = "//input[@id='deliveryMethod' and @value='AU']"
This module is in the Lib directory.

Now when I do
import selfservicelabels
selfservicelabels.BtnSave
-> link=nmbs.label.save
selfservicelabels.DeliveryAutomaat
-> AttributeError: 'module' object has no attribute
'DeliveryAutomaat'

to make it more strange: PyCrust and Idle recognise DeliveryAutomaat
perfectly.
Everything above is done with Python 2.4.3 on Windows XP SP2

So after some testing it seems to depend on from which partition I
start Python.
So open commandline and navigate to a dir on C: everything works
perfectly.
Close python shell en navigate to D: some variables in
selfservicelabels.py are not known.
What is going on here? Is this a known error?
 
K

Kent Johnson

Chris_147 said:
but it seems to depend on from where I start the Python shell.

so I've got a module selfservicelabels.py with some variables defined,
like this:
BtnSave = "link=label.save"
DeliveryAutomaat = "//input[@id='deliveryMethod' and @value='AU']"
This module is in the Lib directory.

Now when I do
import selfservicelabels
selfservicelabels.BtnSave
-> link=nmbs.label.save
selfservicelabels.DeliveryAutomaat
-> AttributeError: 'module' object has no attribute
'DeliveryAutomaat'

to make it more strange: PyCrust and Idle recognise DeliveryAutomaat
perfectly.
Everything above is done with Python 2.4.3 on Windows XP SP2

So after some testing it seems to depend on from which partition I
start Python.

Probably you have multiple copies of selfservicelabels.py or an old
selfservicelabels.pyc that is being imported. Try
import selfservicelabels
print selfservicelabels.__file__

to see where the import is coming from.

Kent
 
C

Chris_147

Thanks for the reply.

you are indeed right, they were included from different places.
from C:\Python24\Lib and D:\mydir

But the strange thing is:
anywhere on C: the file from C:\Python24\Lib was included.
in D:\mydir the one from that directory
BUT: anywhere else on D: apparantly the one from D:\mydir was included
?!
I would expect it would come from c:\Python24\Lib.

Now I changed the files and of course I cannot reproduce it anymore.
Oh well, now it works.
 
T

Tim Roberts

Chris_147 said:
Thanks for the reply.

you are indeed right, they were included from different places.
from C:\Python24\Lib and D:\mydir

But the strange thing is:
anywhere on C: the file from C:\Python24\Lib was included.
in D:\mydir the one from that directory
BUT: anywhere else on D: apparantly the one from D:\mydir was included
?!
I would expect it would come from c:\Python24\Lib.

** PLEASE ** do not copy your OWN files into c:\Python24\Lib. That
directory is intended to contain ONLY the Python standard library.

Modules that are part of a single project should be in a common directory
for that project. Modules that are of general interest to you for multiple
projects should be in \Python24\Lib\site-packages.
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top