[Ironpython-users] Using pyc.py get import error on minimal WPF app

Chaim Krause chaim at chaim.com
Tue Jul 5 19:21:26 CEST 2011


If I copy the dll into the same directory as the exe AND modify the 
code to...

import clr
clr.AddReferenceToFileAndPath("IronPython.Wpf.dll")
import  wpf

THEN it works. So, yes. It appears that something is wrong with the 
import.

Has anybody else experienced this with the latest beta?

Can somebody else on the list who hasn't moved to the beta test this 
and see if it is a regression or has existed in prior versions?

With you input I will open/update a bug on this topic.

On Tuesday, July 05, 2011 11:38:22 AM, Chaim Krause wrote:
> I tried that, with no luck.
> 
> However, that is the same way I am leaning. Especially if I use 
> /target:exe instead of /target:winexe as I then get an exception 
> immediately in the console window:
> 
> [C:\work\Iron Python Sandbox\WpfApplication1]WpfApplication1.exe
> 
> Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: No 
> module named wpf
> at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value)

> at DLRCachedCode.__main__$1(CodeContext $globalContext, FunctionCode 
> $functionCode)
> at IronPython.Compiler.OnDiskScriptCode.Run()
> [snip]
> 
> On Tuesday, July 05, 2011 11:21:48 AM, Jeff Hardy wrote:
>> Hi Chaim,
>> My guess is that it can't find the wpf module - which, in 2.7 at
>> least, is IronPython.Wpf.dll. You'll probably need to put that file
>> (from the DLLs directory of IronPython) into the same folder as your
>> .exe.
>>
>> - Jeff
>>
>> On Tue, Jul 5, 2011 at 6:59 AM, Chaim Krause<chaim at chaim.com> wrote:
>>> Runs fine in IronPython IDE /Visual Stud
> io 2010, but...
>>>
>>> Using minimal code:
>>>
>>> import wpf
>>>
>>> from System.Windows import Application, Window
>>>
>>> class MyWindow(Window):
>>> def __init__(self):
>>> wpf.LoadComponent(self, 'WpfApplication1.xaml')
>>>
>>>
>>> if __name__ == '__main__':
>>> Application().Run(MyWindow()
>>>
>>> Compiling using pyc.py and attempting to run resulting EXE I get an 
>>> error in
>>> windows' application e
vent log
>>>
>>> Application: WpfApplication1.exe
>>> Framework Version: v4.0.30319
>>> Description: The process was terminated due to an unhandled exception.
>>> Exception Info: IronPython.Runtime.Exceptions.ImportException
>>> Stack:
>>> at
>>> Microsoft.Scripting.Interpreter.Interpreter.Run(Microsoft.Scripting.Interpreter.InterpretedFrame) 
>>>
>>> at Microsoft.Scripting.Interpreter.LightLambda.Run8[[System.__Canon,
>>> mscorlib, Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5
> c561934e089],[System.__Canon, mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, 
>>> mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neu
tral, PublicKeyToken=b77a5c561934e089],[System.__Canon, 
>>> mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, 
>>> mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089]](System.__Canon, System.__Canon,
>>> System.__Canon, System.__Canon, System.__Canon, System.__Canon,
>>> System.__Canon, Int32)
>>> at System.Dynamic.UpdateDelegates.UpdateAndExecute7[[System.__Canon,
>>> mscorlib, Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[Sys
> tem.__Canon, mscorlib, Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, 
>>> mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, 
>>> mscorlib,
>>> Ver
sion=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, 
>>> mscorlib,
>>> Version=4.0.0.0, Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, 
>>> Version=4.0.0.0,
>>> Culture=neutral,
>>> PublicKeyToken=b77a5c561934e089]](System.Runtime.CompilerServices.CallSite, 
>>>
>>> System.__Canon, System.__Canon, System.__Canon, System.__Canon,
>>> System.__Canon, System.__Canon, Int32)
>>> at
>>> IronPython.Runtime.Importer.ImportLightThrow(IronPython.Runtime.CodeContext, 
>>>
>>> System.String, IronPython.Runtime.PythonTuple, Int32)
>>> a
> t
>>> IronPython.Runtime.Operations.PythonOps.InitializeModule(System.Reflection.Assembly, 
>>>
>>> System.String, System.String[])
>>> at PythonMain.Main()
>>>
>>> _______________________________________________
>>> Ironpython-users mailing list
>>> Ironpython-users at python.org
>>> http:/
/mail.python.org/mailman/listinfo/ironpython-users
>>>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users


More information about the Ironpython-users mailing list