[IronPython] Distributing scripts as Exe

David DiCato ddicato at microsoft.com
Fri Apr 30 18:56:37 CEST 2010


How does your program figure out where to find the standard library? Is it relying on the IRONPYTHONPATH environment variable to point to the location of the standard lib? If so, this is currently broken in pyc.py-generated executables and is a known bug: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=26706.

As a workaround, you can get the IRONPYTHONPATH environment variable explicitly. If it's not set, try copying "c:\Program Files\IronPython 2.6\Lib" into your program directory. Either way, putting the following code into the beginning of your program should help:

import sys
from System.Environment import GetEnvironmentVariable
ipypath = GetEnvironmentVariable('IRONPYTHONPATH')
if ipypath:
    sys.path.extend(ipypath.split(';'))
else:
    # IRONPYTHONPATH not set, use standard lib redist
    sys.path.append(".\\Lib")

If this doesn't help, try running your program from the command line. After you get rid of the "X.exe has stopped working..." dialog, copy/paste any output you see and send it back to the list (or send it to me personally if confidentiality is desired).

- David

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mico Siahaan
Sent: Thursday, April 29, 2010 6:21 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Distributing scripts as Exe

Hi David, I already put all *.dll files into my program directory but got the same problem. Unluckily Windows did not show details of what went wrong. So I have no idea what did really happen.

Rgds,

---
Mico | mico.siahaan at gmail.com | @bangmico

-----Original Message-----
From: David DiCato <ddicato at microsoft.com>
Date: Thu, 29 Apr 2010 22:13:46 
To: Discussion of IronPython<users at lists.ironpython.com>
Subject: Re: [IronPython] Dirstributing scripts as Exe

This is probably an assembly load failure. Try copying "c:\Program Files\IronPython 2.6"\*.dll into your program directory. You will also need to make sure that sys.path is properly set if you're using the CPython standard lib for anything.

We realize this is kind of an undesirable workaround, which is why we're planning to put all of IronPython's required DLLs in the GAC at some point in the future.

- David

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mico Siahaan
Sent: Thursday, April 29, 2010 3:04 PM
To: Users at lists.ironpython.com
Subject: [IronPython] Dirstributing scripts as Exe

Dear all,

In CPython there is py2exe to distribute scripts as exe. I notice
there is pyc.py scripts in IronPython\Tools. I tried to use pyc to
compile one simple script. It produced an exe file. But when I tried
to run the exe file, Windows complained: 'Windows stop working...'.
Did I do something wrong?

-- 
Mico | mico.siahaan at gmail.com | @bangmico
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list