Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51726 > unrolled thread

Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run

Started byalesssia <alessia.visconti@gmail.com>
First post2013-08-01 02:49 -0700
Last post2013-08-01 23:43 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run alesssia <alessia.visconti@gmail.com> - 2013-08-01 02:49 -0700
    Re: Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run Dave Angel <davea@davea.name> - 2013-08-01 12:39 +0000
      Re: Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run alesssia <alessia.visconti@gmail.com> - 2013-08-01 12:15 -0700
        Re: Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run Dave Angel <davea@davea.name> - 2013-08-01 23:43 +0000

#51726 — Python and PyQt (Windows) - AttributeError: 'module' object has not attribute run

Fromalesssia <alessia.visconti@gmail.com>
Date2013-08-01 02:49 -0700
SubjectPython and PyQt (Windows) - AttributeError: 'module' object has not attribute run
Message-ID<1414fafe-bc3c-4795-87db-3e8ece51f2c5@googlegroups.com>
I developed a python3-PyQt4 application (I’m a newbie!) on a 32-bit Linux platform, and I’m experiencing some problems when testing it on Windows platforms (Windows 7 and 8, both 64-bit).

I have a module called Pmc.py that contains two methods: run and main, but only the former is used in the PyQt main class. I import the module using the following statement:

          import Pmc

and I call the function run with the following instruction:

          self.results = Pmc.run(self.p, self.m)

obtaining this error:

          AttributeError: 'module' object has not attribute run

After some tests, I discovered that renaming Pmc.py in pmc.py solves my issue. No problems are present when using Linux both 32 and 64 bit. 
I’m using python 3.3 and PyQt 4. 

What am I missing?

Thanks in advance,
Alessia

[toc] | [next] | [standalone]


#51728

FromDave Angel <davea@davea.name>
Date2013-08-01 12:39 +0000
Message-ID<mailman.75.1375360769.1251.python-list@python.org>
In reply to#51726
alesssia wrote:

> I developed a python3-PyQt4 application (I’m a newbie!) on a 32-bit Linux platform, and I’m experiencing some problems when testing it on Windows platforms (Windows 7 and 8, both 64-bit).
>
> I have a module called Pmc.py that contains two methods: run and main, but only the former is used in the PyQt main class. I import the module using the following statement:
>
>           import Pmc
>
> and I call the function run with the following instruction:
>
>           self.results = Pmc.run(self.p, self.m)
>
> obtaining this error:
>
>           AttributeError: 'module' object has not attribute run

When quoting something from your tests, please don't paraphrase or
shorten.  The actual error traceback starts with a line "Traceback (..."
and is several lines long, and the line you did quote is missing some
quotes and uses the word 'not' when i.t was originally 'no'.

In this case, it doesn't matter, but frequently it will.

>
> After some tests, I discovered that renaming Pmc.py in pmc.py

I don't know what that means. Strictly speaking I think that means you
edited the content of pmc.py and renamed its use of the string to
something else.  But I think you're trying to say you renamed Pmc.py to
pmc.py.  That seems backwards to me.  The reverse is more likely to fix
the problem.

> solves my issue. No problems are present when using Linux both 32 and
> 64 bit. 
> I’m using python 3.3 and PyQt 4. 
>
> What am I missing?

Linux is sensitive to case, while Windows is not.  Windows does, however
preserve the case when you look a the directory, either manually with
DIR, or via some Python function.

My guess is that somehow when the zip file was extracted, the case of
this file was not preserved, and it came out  pmc.py.

My suggestion is to simply use all lower-case for your filenames, and
change the references within your source to

   import pmc
   self.results = pmc.run

Pep-8 recommends that you use an uppercase leading letter to indicate a
class name.  So a class of the "same" name as the file would be
     obj = pmc.Pmc(args)

Another possibility is that you have both a pmc.py  AND a Pmc.py. 
That's not legal in Windows, at least if they're in the same directory. 
And it's not advisable in Windows, if they're even in the same project.


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#51756

Fromalesssia <alessia.visconti@gmail.com>
Date2013-08-01 12:15 -0700
Message-ID<aaa2817b-5118-49c2-a749-4bc263020c0b@googlegroups.com>
In reply to#51728
>> After some tests, I discovered that renaming Pmc.py in pmc.py 
> I don't know what that means.

I simply renamed Pmc.py to pmc.py, using a lower case instead of an upper case. Of course, I also changed lines referencing to 'Pmc' (upper case) to 'pmc' (lover case) in the source code. This allows my program to work.

> My guess is that somehow when the zip file was extracted, the case of 
> this file was not preserved, and it came out  pmc.py.

The zip was not extracted because there was no zip. I copied the code from my computer to a USB pen drive and ran the code from there.


> My suggestion is to simply use all lower-case for your filenames

What surprised me is that Windows was unable of holding upper case, so I thought there was something else.  Yet, it seems that this behaviour does not surprise anyone else. Then, I'll simply changes all my source file names, despite I felt it silly...

Thanks,
Alessia

[toc] | [prev] | [next] | [standalone]


#51770

FromDave Angel <davea@davea.name>
Date2013-08-01 23:43 +0000
Message-ID<mailman.100.1375400624.1251.python-list@python.org>
In reply to#51756
alesssia wrote:

   <snip>

>> My guess is that somehow when the zip file was extracted, the case of 
>> this file was not preserved, and it came out  pmc.py.
>
> The zip was not extracted because there was no zip. I copied the code from my computer to a USB pen drive and ran the code from there.

That's probably where you lost the case distinction.  The FAT file
system doesn't really support lowercase, except with 'extended
attributes', and probably your Linux system didn't create those in a way
that Windows was happy with.

If I had to get files between the two, I'd either use Linux tools to do
the transfer (eg. scp or ftp), or I'd zip the files and just transfer
the zip.

>
>
>> My suggestion is to simply use all lower-case for your filenames
>
> What surprised me is that Windows was unable of holding upper case, so I thought there was something else.  Yet, it seems that this behaviour does not surprise anyone else. Then, I'll simply changes all my source file names, despite I felt it silly...
>

It can hold uppercase;  in fact, it's lower case that's "new".  But
because it's "case - preserving" rather than "case -sensitive",
sometimes it's a mess.

-- 
DaveA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web