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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris_147

    #1

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

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

    so I've got a module selfservicelabe ls.py with some variables defined,
    like this:
    BtnSave = "link=label.sav e"
    DeliveryAutomaa t = "//input[@id='deliveryMe thod' and @value='AU']"
    This module is in the Lib directory.

    Now when I do
    import selfservicelabe ls
    selfservicelabe ls.BtnSave
    -> link=nmbs.label .save
    selfservicelabe ls.DeliveryAuto maat
    -> AttributeError: 'module' object has no attribute
    'DeliveryAutoma at'

    to make it more strange: PyCrust and Idle recognise DeliveryAutomaa t
    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
    selfservicelabe ls.py are not known.
    What is going on here? Is this a known error?

  • Kent Johnson

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

    Chris_147 wrote:[color=blue]
    > but it seems to depend on from where I start the Python shell.
    >
    > so I've got a module selfservicelabe ls.py with some variables defined,
    > like this:
    > BtnSave = "link=label.sav e"
    > DeliveryAutomaa t = "//input[@id='deliveryMe thod' and @value='AU']"
    > This module is in the Lib directory.
    >
    > Now when I do
    > import selfservicelabe ls
    > selfservicelabe ls.BtnSave
    > -> link=nmbs.label .save
    > selfservicelabe ls.DeliveryAuto maat
    > -> AttributeError: 'module' object has no attribute
    > 'DeliveryAutoma at'
    >
    > to make it more strange: PyCrust and Idle recognise DeliveryAutomaa t
    > 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.[/color]

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

    to see where the import is coming from.

    Kent
    [color=blue]
    > So open commandline and navigate to a dir on C: everything works
    > perfectly.
    > Close python shell en navigate to D: some variables in
    > selfservicelabe ls.py are not known.
    > What is going on here? Is this a known error?
    >[/color]

    Comment

    • Chris_147

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

      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.

      Comment

      • Tim Roberts

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

        "Chris_147" <chris.van.bael @gmail.com> wrote:
        [color=blue]
        >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 .[/color]

        ** 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\s ite-packages.
        --
        - Tim Roberts, timr@probo.com
        Providenza & Boekelheide, Inc.

        Comment

        Working...