[IronPython] System.MissingMemberException / pyc.py

Andrew Buchan mr_buchan at hotmail.com
Mon Dec 29 23:37:23 CET 2008

I'm encountering problems when compiling files using the pyc sample for 2.0:
My (close to first) IronPython program runs fine when called from DOS console, but when compiled into an exe using pyc, I get the following error when running the exe (debug in Visual Studio 2008):
 System.MissingMemberException:  "'namespace#' object has no attribute 'File'" 
The piece of code this ties back to is:
def isFileValid(filename):    att = System.IO.File.GetAttributes(filename)    mask = att.value__    if ((mask & System.IO.FileAttributes.Hidden.value__) or (mask & System.IO.FileAttributes.System.value__)):       return False    else:       return True
The above is not in a class, its just a function in a module which is imported into the main py file.
I'm no expert on the matter, and as far as I can see it seems to be telling me that System.IO does not have an Attribute 'File', which according to MSDN and by inference from the fact the program works when called from DOS console, it does.
What bugs me about this (pun half intended) is that a presumably correctly compiled exe behaves differently to how the original py file ran via ipy.exe does with reference to using libraries (before I got to this bug I also had to change/rectify how I was importing standard libraries as the compiled exe requires you to specifically add the path to standard python lib, but ipy.exe interpreter doesn't...).
Have I stumbled upon an exception, or a small category of 'gotchas'; or is it common for a compiled IronPython application to run differently from the py files run using ipy.exe due to a number of possible reasons?
If the latter is true, then I see little point in running the py files during development/testing of small .exe applications, you'd be better compiling afresh every run.
The irony of all this is that the application in question is a simple GUI tool to navigate folders, select python files and either Run (calling IPY.exe), or Compile (using pyc and copying in the required dlls etc...), all to save me the bother of doing these tasks with the DOS console. 
Any clues as to where to go with the "'namespace#' object has no attribute 'File'" issue?

 Live Search presents Big Snap II - win John Lewis vouchers 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081229/c9be17e6/attachment.html>

More information about the Ironpython-users mailing list