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

Kent Johnson kent at kentsjohnson.com
Tue May 23 11:52:12 EDT 2006


Chris_147 wrote:
> 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

> 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?
> 



More information about the Python-list mailing list