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


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to