[Ironpython-users] IPY 2.7.2.1. Using pyc.py for standalone exe
Dominique de Waleffe
ddewaleffe at gmail.com
Thu Mar 15 16:16:24 CET 2012
Will try your suggestion and I will also spend a bit of time to construct
the list of needed dependencies so that pyc can do a better job...
Will also file an issue later on today.
D.
############################
# Dominique de Waleffe
# ddewaleffe -at- gmail -dot- com
# domi -at- dewaleffe -dot- org
############################
On Thu, Mar 15, 2012 at 3:24 PM, Slide <slide.o.mix at gmail.com> wrote:
> There is no need to use the CPython stdlib, the IP installer comes with a
> stdlib that has some mods for it to work better. Check the Lib directory
> where you installed IP. Also, you can set IRONPYTHONPATH to have it find
> things.
> On Mar 15, 2012 5:49 AM, <mchalkley at mail.com> wrote:
>
>> Thursday, March 15, 2012, 3:49:36 AM, you wrote:
>>
>>
>> I am not sure whether this should be expected to work or not, nor if I
>> am using this correctly...
>>
>> I tried to generate a standalone exe for a tool I have (3 modules) but it
>> bombs out at startup with:
>>
>> Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: No
>> module named os
>> at DLRCachedCode.__main__$1(CodeContext $globalContext, FunctionCode
>> $functionCode)
>> at IronPython.Compiler.OnDiskScriptCode.Run()
>> at IronPython.Runtime.PythonContext.InitializeModule(String fileName,
>> ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
>> at IronPython.Runtime.ModuleLoader.load_module(CodeContext context,
>> String fullName)
>> at
>> Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame
>> frame)
>> at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame
>> frame)
>> at
>> Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0,
>> T1 arg1, T2 arg2, T3 arg3)
>>
>> I can reproduce with this simple foo.py module
>>
>> # foo.py
>> import os
>> print "Hello"
>> print "OS:",os.name
>> print "Bye"
>> #end foo.py
>>
>> which I compile with the following:
>>
>> ipy -m pyc /standalone /main:foo.py /target:exe /out:foo
>> or
>> ipy -m pyc /main:foo.py /target:exe /out:foo2
>>
>> Starting either foo.exe or foo2.exe fails with above error.
>>
>> If I remove the import os and the line that uses on.name, I get an
>> executable that works...
>>
>> Is this a bug or a misunderstanding in what I expect to work?
>> If so what are the correct steps?
>>
>> Thanks for your help
>>
>> D.
>>
>> ############################
>> # Dominique de Waleffe
>> # ddewaleffe -at- gmail -dot- com
>> # domi -at- dewaleffe -dot- org
>> ############################
>>
>> I'll try to help, since I got a lot of help with something similar
>> recently. Congratulations - you got further before asking for help than I
>> did...
>>
>> It seems that you don't have the path to your CPython directory in your
>> environment variables. I thought installing IronPython automatically set
>> those variables, but maybe CPython got moved or something? In any case,
>> you can add it like this:
>>
>> import sys
>> sys.path.append(r"c:\python24\lib")
>>
>> And if you plan on distributing the exe to another machine that doesn't
>> have CPython installed, you need to put a copy of all the modules your
>> script needs in a zip file located in the same directory as the exe and put
>> the line
>>
>> sys.path.append('zipfile.zip')
>>
>> in your script before importing those modules...
>>
>> Mark
>>
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> http://mail.python.org/mailman/listinfo/ironpython-users
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120315/ee11687a/attachment.html>
More information about the Ironpython-users
mailing list