py2exe, import enthought

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

py2exe, import enthought

billy.robertson
Hi,

I am attempting to build a python program to an .exe file using py2exe. The program uses enthought to generate the GUI and the .exe file produced initialises but fails to run fully. I suspect this is because the setup file does not explicitly say to import the enthought module. How can I tell my setup file to do this?

Currently my setup file is as follows.

from distutils.core import setup
import py2exe
import sys
from glob import glob

sys.path.append("C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91")

data_files = [("Microsoft.VC90.CRT", glob(r'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*'))]
setup(
    data_files=data_files
      )

setup(console=['GUIProgram.py'])

Any suggestions are appreciated. Thanks.  

Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Didrik Pinte-2
On Mon, Aug 15, 2011 at 3:40 PM, billy.robertson
<[hidden email]> wrote:
> Hi,
>
> I am attempting to build a python program to an .exe file using py2exe. The
> program uses enthought to generate the GUI and the .exe file produced
> initialises but fails to run fully.

A copy of the error would help.

>I suspect this is because the setup file
> does not explicitly say to import the enthought module. How can I tell my
> setup file to do this?

There is example posted some weeks ago by Thomas that could probably help :

http://www.geophysique.be/en/2010/10/29/pack-an-enthought-traits-app-inside-a-exe-using-py2exe/

-- Didrik
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
I don't get an error message. When I double click on the icon in the dist folder the command window appears briefly then it dissapears. Thats all that it seems to do.
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Didrik Pinte-2
On Mon, Aug 15, 2011 at 4:06 PM, billy.robertson
<[hidden email]> wrote:
> I don't get an error message. When I double click on the icon in the dist
> folder the command window appears briefly then it dissapears. Thats all that
> it seems to do.

Can you start the exe from the command line ? It should be more verbose.

-- Didrik
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
This is what I got:

Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Didrik Pinte-2
On Mon, Aug 15, 2011 at 4:14 PM, billy.robertson
<[hidden email]> wrote:
> This is what I got:
>
> http://enthought-dev.117412.n3.nabble.com/file/n3255868/Untitled.png

py2exe has most probably not collected the pyface wx or qt backend
needed to run the code. This will be solved by forcing some of the
imports.

-- Didrik
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Thomas Lecocq

Dear,

for your info, I updated my tutorial to match the new ETS 4.x namespace :

http://www.geophysique.be/en/2011/08/01/pack-an-enthought-traits-app-inside-a-exe-using-py2exe-ets-4-0-edit/

Cheers,

Thom

**********************
Dr Thomas Lecocq
Geologist
Royal Observatory of Belgium

- Seismology -
**********************


> Date: Mon, 15 Aug 2011 16:18:26 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Enthought-Dev] py2exe, import enthought
>
> On Mon, Aug 15, 2011 at 4:14 PM, billy.robertson
> <[hidden email]> wrote:
> > This is what I got:
> >
> > http://enthought-dev.117412.n3.nabble.com/file/n3255868/Untitled.png
>
> py2exe has most probably not collected the pyface wx or qt backend
> needed to run the code. This will be solved by forcing some of the
> imports.
>
> -- Didrik
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
     
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
In reply to this post by Didrik Pinte-2
I looked at the example which helped, however I'm not there yet. It now displays this error:



My setup file is very similar but I had to remove these lines to get it to work:

    includes.append('enthought.enable.image')
    includes.append('enthought.enable.image_title')
    includes.append('enthought.enable.wx_backend')

I think the file I need is somewhere in my python folder, however I don't know where. I am aware that my folders are probably named slightly differently from other peoples but any ideas where to start looking? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Thomas Lecocq

Billy,

did you use the ETS 4.0 version of my tutorial ?

Thom



**********************
Dr Thomas Lecocq
Geologist
Royal Observatory of Belgium

- Seismology -
**********************


> Date: Tue, 16 Aug 2011 05:27:11 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Enthought-Dev] py2exe, import enthought
>
> I looked at the example which helped, however I'm not there yet. It now
> displays this error:
>
> http://enthought-dev.117412.n3.nabble.com/file/n3258484/Untitled2.png 
>
> My setup file is very similar but I had to remove these lines to get it to
> work:
>
>     includes.append('enthought.enable.image')
>     includes.append('enthought.enable.image_title')
>     includes.append('enthought.enable.wx_backend')
>
> I think the file I need is somewhere in my python folder, however I don't
> know where. I am aware that my folders are probably named slightly
> differently from other peoples but any ideas where to start looking? Thanks.
>
> --
> View this message in context: http://enthought-dev.117412.n3.nabble.com/py2exe-import-enthought-tp3255778p3258484.html
> Sent from the Enthought Dev mailing list archive at Nabble.com.
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
     
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
No, I used the ETS 3.5 tutorial. The version I am using is 3.6 so I was considering installing 4.0 and hopefully my program would still run ok in python then I could follow your 4.0 example.
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Thomas Lecocq

Billy,

Ok, so it shouldn't be too hard to get it working . I don't know why you had to remove the lines from the example setup.py in my tutorial. What is the error message you get when you leave them ? Have you checked your folder strucutre in order to see if "something like I wrote" does exist ?

I suppose your program runs smoothly simply using python myprogramname.py ?

BTW : do you use WX or QT backends for your program ?

Cheers,

Thom

ps : try to provide as much information as possible when requesting help, it's uneasy to debug in the dark...



**********************
Dr Thomas Lecocq
Geologist
Royal Observatory of Belgium

- Seismology -
**********************


> Date: Tue, 16 Aug 2011 07:55:44 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Enthought-Dev] py2exe, import enthought
>
> No, I used the ETS 3.5 tutorial. The version I am using is 3.6 so I was
> considering installing 4.0 and hopefully my program would still run ok in
> python then I could follow your 4.0 example.
>
> --
> View this message in context: http://enthought-dev.117412.n3.nabble.com/py2exe-import-enthought-tp3255778p3258883.html
> Sent from the Enthought Dev mailing list archive at Nabble.com.
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
     
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
The error message with the lines included was:



Then with that one line removed the error was the same except with the different module name.

My folder structure is much the same except for example 'TraitsBackendWX-3.6.0-py2.6.egg' instead of 'TraitsBackendWX'.

My program runs fine from the python. I am unsure what backends I am using but I suspect its wx, is there a way to find out?

My setup file at the moment is:

from distutils.core import setup
import py2exe
import os
import enthought
   
includes = []
includes.append('numpy')
includes.append('scipy')
includes.append('numpy.core')
includes.append('wx')
includes.append('wx.*')
includes.append('enthought')
includes.append('enthought.kiva')
includes.append('enthought.traits')
#includes.append('enthought.traits.wx')
includes.append('enthought.traits.ui')
includes.append('enthought.traits.ui.wx')
includes.append('enthought.traits.ui.wx.*')
includes.append('enthought.pyface.*')
includes.append('enthought.pyface.ui.*')
includes.append('enthought.pyface.ui.wx.*')
includes.append('enthought.pyface.ui.wx.action.*')
includes.append('enthought.pyface.ui.wx.timer.*')
includes.append('enthought.pyface.ui.wx.wizard.*')
includes.append('enthought.pyface.ui.wx.workbench.*')
includes.append('enthought.enable')
includes.append('enthought.enable.*')
includes.append('enthought.enable.drawing')
#includes.append('enthought.enable.image')
#includes.append('enthought.enable.image_title')
includes.append('enthought.enable.traits')
#includes.append('enthought.enable.wx_backend')  

packages = []  

ETS_folder = r'C:\Python26\Lib\site-packages'  

data_folders = []  

data_folders.append( ( os.path.join(ETS_folder,r'TraitsGUI-3.6.0-py2.6.egg\enthought\pyface\images') , 'enthought/pyface/images') )

data_folders.append( ( os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable\images') , 'enthought/enable/images') )

data_folders.append( ( os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\pyface\ui\wx\images') , 'enthought/pyface/ui/wx/images') )

data_folders.append( ( os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\traits\ui\wx\images') , 'enthought/traits/ui/wx/images') )  

data_folders.append( ( os.path.join(ETS_folder,r'TraitsGUI-3.6.0-py2.6.egg\enthought\traits\ui\image\library') , 'enthought/traits/ui/image/library') )

data_folders.append( ( os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable') , 'enthought/enable') )

data_folders.append( ( os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\traits\ui\wx') , 'enthought/traits\ui\wx') )

data_folders.append( ( os.path.join(ETS_folder,r'Traits-3.6.0-py2.6-win32.egg\enthought\traits\ui') , 'enthought/traits\ui') )

data_folders.append( ( os.path.join(ETS_folder,r'matplotlib') , 'matplotlib') )

data_files = []
 
for folder, relative_path in data_folders:    
    for file in os.listdir(folder):        
        f1 = os.path.join(folder,file)        
        if os.path.isfile(f1): # skip directories            
            f2 = relative_path, [f1]            
            data_files.append(f2)  
       
setup(console=['TaliskerManGUI.py'],  
     
      options = {"py2exe": {    "optimize": 0,                              
                                "packages": packages,                              
                                "includes": includes,                              
                                "dist_dir": 'dist',                              
                                "bundle_files":2,                              
                                "xref": False,                              
                                "skip_archive": True,                              
                                "ascii": False,                              
                                "custom_boot_script": '',                              
                                "compressed":False,                              
                                },},    
    data_files=data_files)


My program uses these modules:

from enthought.traits.api import *
from enthought.traits.ui.api import *
from enthought.enable.api import *
from enthought.chaco.api import *
from enthought.enable.component_editor import *
from enthought.chaco.chaco_plot_editor import ChacoPlotItem
from enthought.chaco.tools.api import BroadcasterTool, PanTool, ZoomTool, \
    LegendTool, TraitsTool, DragZoom, LineInspector
from enthought.chaco.tools.cursor_tool import CursorTool, BaseCursorTool
from scipy import array
from numpy import arange
# Import my own module which does the ABCD modelling
from ABCD import *


Thanks,

Billy
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Thomas Lecocq


when using python from the command prompt, can you import enthought.traits.wx ?

usually, the error messages that the exe gives is indicative of what you have to include :

for example, if it says "traits.ui.wx_backend has no module named image", you might want to check your sources in something like TraitsBackendWX/enthought/traits/ui/wx/images and include this in the setup, then rerun the build, start the exe and so on... it's a bit long, but usually within some 5 or 10 steps, it should work.

NOTE : you can't bundle all files in ONE exe, it actually doesn't work now (please keep my optimize, bundle and skip_archive parameters).

Thom

**********************
Dr Thomas Lecocq
Geologist
Royal Observatory of Belgium

- Seismology -
**********************


> Date: Tue, 16 Aug 2011 08:42:05 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Enthought-Dev] py2exe, import enthought
>
> The error message with the lines included was:
>
> http://enthought-dev.117412.n3.nabble.com/file/n3259023/Untitled3.png 
>
> Then with that one line removed the error was the same except with the
> different module name.
>
> My folder structure is much the same except for example
> 'TraitsBackendWX-3.6.0-py2.6.egg' instead of 'TraitsBackendWX'.
>
> My program runs fine from the python. I am unsure what backends I am using
> but I suspect its wx, is there a way to find out?
>
> My setup file at the moment is:
>
> /from distutils.core import setup
> import py2exe
> import os
> import enthought
>    
> includes = []
> includes.append('numpy')
> includes.append('scipy')
> includes.append('numpy.core')
> includes.append('wx')
> includes.append('wx.*')
> includes.append('enthought')
> includes.append('enthought.kiva')
> includes.append('enthought.traits')
> #includes.append('enthought.traits.wx')
> includes.append('enthought.traits.ui')
> includes.append('enthought.traits.ui.wx')
> includes.append('enthought.traits.ui.wx.*')
> includes.append('enthought.pyface.*')
> includes.append('enthought.pyface.ui.*')
> includes.append('enthought.pyface.ui.wx.*')
> includes.append('enthought.pyface.ui.wx.action.*')
> includes.append('enthought.pyface.ui.wx.timer.*')
> includes.append('enthought.pyface.ui.wx.wizard.*')
> includes.append('enthought.pyface.ui.wx.workbench.*')
> includes.append('enthought.enable')
> includes.append('enthought.enable.*')
> includes.append('enthought.enable.drawing')
> #includes.append('enthought.enable.image')
> #includes.append('enthought.enable.image_title')
> includes.append('enthought.enable.traits')
> #includes.append('enthought.enable.wx_backend')  
>
> packages = []  
>
> ETS_folder = r'C:\Python26\Lib\site-packages'  
>
> data_folders = []  
>
> data_folders.append( (
> os.path.join(ETS_folder,r'TraitsGUI-3.6.0-py2.6.egg\enthought\pyface\images')
> , 'enthought/pyface/images') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable\images')
> , 'enthought/enable/images') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\pyface\ui\wx\images')
> , 'enthought/pyface/ui/wx/images') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\traits\ui\wx\images')
> , 'enthought/traits/ui/wx/images') )  
>
> data_folders.append( (
> os.path.join(ETS_folder,r'TraitsGUI-3.6.0-py2.6.egg\enthought\traits\ui\image\library')
> , 'enthought/traits/ui/image/library') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable') ,
> 'enthought/enable') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'TraitsBackendWX-3.6.0-py2.6.egg\enthought\traits\ui\wx')
> , 'enthought/traits\ui\wx') )
>
> data_folders.append( (
> os.path.join(ETS_folder,r'Traits-3.6.0-py2.6-win32.egg\enthought\traits\ui')
> , 'enthought/traits\ui') )
>
> data_folders.append( ( os.path.join(ETS_folder,r'matplotlib') ,
> 'matplotlib') )
>
> data_files = []
>  
> for folder, relative_path in data_folders:    
>     for file in os.listdir(folder):        
>         f1 = os.path.join(folder,file)        
>         if os.path.isfile(f1): # skip directories            
>             f2 = relative_path, [f1]            
>             data_files.append(f2)  
>        
> setup(console=['TaliskerManGUI.py'],  
>      
>       options = {"py2exe": {    "optimize": 0,                              
>                                 "packages": packages,                              
>                                 "includes": includes,                              
>                                 "dist_dir": 'dist',                              
>                                 "bundle_files":2,                              
>                                 "xref": False,                              
>                                 "skip_archive": True,                              
>                                 "ascii": False,                              
>                                 "custom_boot_script": '',                              
>                                 "compressed":False,                              
>                                 },},    
>     data_files=data_files) /
>
> My program uses these modules:
>
> /from enthought.traits.api import *
> from enthought.traits.ui.api import *
> from enthought.enable.api import *
> from enthought.chaco.api import *
> from enthought.enable.component_editor import *
> from enthought.chaco.chaco_plot_editor import ChacoPlotItem
> from enthought.chaco.tools.api import BroadcasterTool, PanTool, ZoomTool, \
>     LegendTool, TraitsTool, DragZoom, LineInspector
> from enthought.chaco.tools.cursor_tool import CursorTool, BaseCursorTool
> from scipy import array
> from numpy import arange
> # Import my own module which does the ABCD modelling
> from ABCD import */
>
> Thanks,
>
> Billy
>
> --
> View this message in context: http://enthought-dev.117412.n3.nabble.com/py2exe-import-enthought-tp3255778p3259023.html
> Sent from the Enthought Dev mailing list archive at Nabble.com.
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
     
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
I have no module named 'enthought.traits.wx'. I do have a 'enthought.enable.wx' which i have added to the includes list although it didn't make any difference.

I added the following lines to my setup code:

data_folders.append( ( os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\kiva\traits\ui\wx') , 'enthought/kiva/traits/ui/wx') )

data_folders.append( ( os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable\traits\ui\wx') , 'enthought/enable/traits/ui/wx') )

data_folders.append( ( os.path.join(ETS_folder,r'Enable-3.4.0-py2.6-win32.egg\enthought\enable\wx') , 'enthought/enable/wx') )


This then gave a diiferent error when I tried to run my .exe:



line 4 of my ABCD module uses:    from matplotlib.mlab import find

Also, notice I get a permission denied error, I changed the permissions on this file so it was no longer read only but the error remains. This error also occured when I tried the example setup and program but it didn't prevent the .exe from running. I looked on the internet and found a forum saying it was a bug and it didn't matter.

I have also tried adding all other folders with images in from TraitsGUI and TraitsBackendQT folders but this made no difference, and I already have all images from TraitsBackendWX folder.

I have also edited the last section of my setup file to:

setup(console=['TaliskerManGUI.py'],  
     
      options = {"py2exe": {    "optimize": 0,                              
                                "packages": packages,                              
                                "includes": includes,                                                              
                                "bundle_files":2,                                                              
                                "skip_archive": True,                              
                                },},    
    data_files=data_files)

Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

billy.robertson
I have added a few matplotlib folders and it's finally working. Just need to strip out some folders that aren't needed to get the file size reduced (it's currently about 124MB but at least it runs correctly).

Thanks very much for you help.
Reply | Threaded
Open this post in threaded view
|

Re: py2exe, import enthought

Thomas Lecocq

Billy,

in my tutorial, at the end, there are 2 or 3 lines on "how to include the mpl_data" folders...

Cheers,

Thom

**********************
Dr Thomas Lecocq
Geologist
Royal Observatory of Belgium

- Seismology -
**********************


> Date: Wed, 17 Aug 2011 04:01:46 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Enthought-Dev] py2exe, import enthought
>
> I have added a few matplotlib folders and it's finally working. Just need to
> strip out some folders that aren't needed to get the file size reduced (it's
> currently about 124MB but at least it runs correctly).
>
> Thanks very much for you help.
>
>
> --
> View this message in context: http://enthought-dev.117412.n3.nabble.com/py2exe-import-enthought-tp3255778p3261272.html
> Sent from the Enthought Dev mailing list archive at Nabble.com.
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
     
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev