pyinstaller + no module named pyface.ui

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

pyinstaller + no module named pyface.ui

Kevin Khan
Hi there,

I currently trying to create a stand alone executable using pyinstaller.  In creating the actual exe there is no problem, however when I try to launch it I get the following error:    "no module named pyface.ui".  I am fairly no to python and creating exes so I am not too sure what is causing this error.  I was wondering if someone else had experience with a similar error and might know how to solve it.  It might be worth listing the modules that I am using in my python script:

from traits.api import HasTraits,Range, Instance, Button, Int,Str, \
    on_trait_change
from traitsui.api import View, Item, HSplit, Group, VSplit, HGroup, Label, VGroup
from os.path import isfile
from pyface.api import FileDialog, OK
from enthought.mayavi.core.common import error


from mayavi import mlab
from mayavi.core.ui.api import MlabSceneModel, SceneEditor
from mayavi.core.api import PipelineBase
from tvtk.pyface.api import Scene
from scipy.interpolate import griddata



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

Re: pyinstaller + no module named pyface.ui

Pietro Berkes
Hi Kevin,

PyFace uses some import magic to automatically select between Qt or wx, and so does traitsui. This confuses pyinstaller when it tries to collect all the modules that it needs to package in the executable.

Packaging an ETS application with pyinstaller requires some work, but you can write a recipe that tells it where to find the "hidden" modules, see

Best,
Pietro


On Sun, Mar 3, 2013 at 11:40 PM, Kevin Khan <[hidden email]> wrote:
Hi there,

I currently trying to create a stand alone executable using pyinstaller.  In creating the actual exe there is no problem, however when I try to launch it I get the following error:    "no module named pyface.ui".  I am fairly no to python and creating exes so I am not too sure what is causing this error.  I was wondering if someone else had experience with a similar error and might know how to solve it.  It might be worth listing the modules that I am using in my python script:

from traits.api import HasTraits,Range, Instance, Button, Int,Str, \
    on_trait_change
from traitsui.api import View, Item, HSplit, Group, VSplit, HGroup, Label, VGroup
from os.path import isfile
from pyface.api import FileDialog, OK
from enthought.mayavi.core.common import error


from mayavi import mlab
from mayavi.core.ui.api import MlabSceneModel, SceneEditor
from mayavi.core.api import PipelineBase
from tvtk.pyface.api import Scene
from scipy.interpolate import griddata



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev




--
Pietro Berkes
Scientific software developer
Enthought UK


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

Re: pyinstaller + no module named pyface.ui

Kevin Khan
In reply to this post by Kevin Khan
Hi Pietro,

I appreciate your help.  I was wondering if you could provide me with a small
example of how I can do this.  I must admit I am still a little new to
pyinstaller, so I am not all that familiar with this stuff.

Regards,

Kevin



On Mon, Mar 4, 2013 at 10:31 AM, <[hidden email]> wrote:
Send Enthought-Dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.enthought.com/mailman/listinfo/enthought-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Enthought-Dev digest..."


Today's Topics:

   1. pyinstaller + no module named pyface.ui (Kevin Khan)
   2. Re: plotting problem (Jaidev Deshpande)
   3. Re: View of Str trait (Jaidev Deshpande)
   4. Re: pyinstaller + no module named pyface.ui (Pietro Berkes)
   5. Re: Changing the index mapper on a pre-existing plot
      (Roan LaPlante)


----------------------------------------------------------------------

Message: 1
Date: Sun, 3 Mar 2013 18:40:05 -0500
From: Kevin Khan <[hidden email]>
Subject: [Enthought-Dev] pyinstaller + no module named pyface.ui
To: [hidden email]
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi there,

I currently trying to create a stand alone executable using pyinstaller.
 In creating the actual exe there is no problem, however when I try to
launch it I get the following error:    "no module named pyface.ui".  I am
fairly no to python and creating exes so I am not too sure what is causing
this error.  I was wondering if someone else had experience with a similar
error and might know how to solve it.  It might be worth listing the
modules that I am using in my python script:

from traits.api import HasTraits,Range, Instance, Button, Int,Str, \
    on_trait_change
from traitsui.api import View, Item, HSplit, Group, VSplit, HGroup, Label,
VGroup
from os.path import isfile
from pyface.api import FileDialog, OK
from enthought.mayavi.core.common import error


from mayavi import mlab
from mayavi.core.ui.api import MlabSceneModel, SceneEditor
from mayavi.core.api import PipelineBase
from tvtk.pyface.api import Scene
from scipy.interpolate import griddata
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.enthought.com/pipermail/enthought-dev/attachments/20130303/e66673b0/attachment-0001.html

------------------------------

Message: 2
Date: Mon, 4 Mar 2013 10:33:08 +0530
From: Jaidev Deshpande <[hidden email]>
Subject: Re: [Enthought-Dev] plotting problem
To: [hidden email]
Message-ID:
        <CAB=[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

On Fri, Mar 1, 2013 at 3:34 AM, Harold Mills <[hidden email]> wrote:
> The script below demonstrates a problem I'm having with an ETS-based
> application that updates two plots (identical here to shorten the script) in
> response to changes to a single parameter. On my system (Windows Vista SP2,
> Python 2.7.2, ETS 4.0.0, wxPython 2.8.12.1), updates to the top plot in
> response to dragging the slider are snappy, but updates to the bottom plot
> and the text field are sluggish. Most of the time, the bottom plot and the
> text field do not not update during the drag, only at the end. Am I doing
> something wrong? What can I do to improve the responsiveness of the second
> plot and the text field?
>
> Thanks,
>
>     Harold Mills
>
>
> from chaco.api import ArrayPlotData, DataRange1D, Plot
> from enable.api import ComponentEditor
> from traits.api import HasTraits, Instance, Range
> from traitsui.api import Item, RangeEditor, VGroup, View
> import numpy as np
>
> TWO_PI = 2 * np.pi
> N = 1000
>
> class PlottingProblem(HasTraits):
>
>     theta = Range(0., TWO_PI)
>     plot_data = Instance(ArrayPlotData)
>     plot_a = Instance(Plot)
>     plot_b = Instance(Plot)
>
>     traits_view = View(
>         VGroup(
>             Item('plot_a', editor = ComponentEditor(), show_label = False),
>             Item('plot_b', editor = ComponentEditor(), show_label = False),
>             Item('theta', label = 'Theta',
>                  editor = RangeEditor(low = 0, high = TWO_PI))),
>         title = 'Plotting Problem',
>         width = 500,
>         resizable = True)
>
>     def __init__(self, *args, **kwargs):
>         HasTraits.__init__(self, *args, **kwargs)
>         self.plot_data = ArrayPlotData(x = TWO_PI * np.arange(N) / float(N))
>         self._theta_changed()
>         self.plot_a = self._create_plot()
>         self.plot_b = self._create_plot()
>
>     def _theta_changed(self):
>         x = self.plot_data.get_data('x')
>         self.plot_data.set_data('y', np.sin(x + self.theta))
>
>     def _create_plot(self):
>         plot = Plot(self.plot_data)
>         plot.index_range = DataRange1D(low = 0, high = TWO_PI)
>         plot.value_range = DataRange1D(low = -1, high = 1)
>         plot.plot(('x', 'y'), type = 'line', name = 'sine')
>         return plot
>
> PlottingProblem().configure_traits()
>
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>

As far as I can tell the programme is correct. Have you tried changing
the backend to qt4? I tried it on both qt and wx and it works pretty
smoothly.

--
JD


------------------------------

Message: 3
Date: Mon, 4 Mar 2013 10:41:23 +0530
From: Jaidev Deshpande <[hidden email]>
Subject: Re: [Enthought-Dev] View of Str trait
To: [hidden email]
Message-ID:
        <CAB=[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

On Thu, Feb 28, 2013 at 5:16 AM, Pedro Miguel Duarte <[hidden email]> wrote:
> Hi, I have a question about the view of a Str trait.  How do I get it to
> display a width of just two lines?
>
> If i do something like
>
> Item('strtrait', style='custom')

The editors available for String traits have nothing that specify the
number of lines in the editor, beyond single and mulit-line. But the
Item class has a height and a width parameter. Maybe you could try
playing around with them.

>
> It always displays a field that has many more lines that I would want to
> see.
>
> Thanks for your help!
>
> Pedro
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>

HTH

--
JD


------------------------------

Message: 4
Date: Mon, 4 Mar 2013 08:25:05 +0000
From: Pietro Berkes <[hidden email]>
Subject: Re: [Enthought-Dev] pyinstaller + no module named pyface.ui
To: [hidden email]
Message-ID:
        <CAHorhT=[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi Kevin,

PyFace uses some import magic to automatically select between Qt or wx, and
so does traitsui. This confuses pyinstaller when it tries to collect all
the modules that it needs to package in the executable.

Packaging an ETS application with pyinstaller requires some work, but you
can write a recipe that tells it where to find the "hidden" modules, see
http://www.pyinstaller.org/export/v2.0/project/doc/Manual.html?format=raw#listing-hidden-imports

Best,
Pietro


On Sun, Mar 3, 2013 at 11:40 PM, Kevin Khan <[hidden email]> wrote:

> Hi there,
>
> I currently trying to create a stand alone executable using pyinstaller.
>  In creating the actual exe there is no problem, however when I try to
> launch it I get the following error:    "no module named pyface.ui".  I am
> fairly no to python and creating exes so I am not too sure what is causing
> this error.  I was wondering if someone else had experience with a similar
> error and might know how to solve it.  It might be worth listing the
> modules that I am using in my python script:
>
> from traits.api import HasTraits,Range, Instance, Button, Int,Str, \
>     on_trait_change
> from traitsui.api import View, Item, HSplit, Group, VSplit, HGroup, Label,
> VGroup
> from os.path import isfile
> from pyface.api import FileDialog, OK
> from enthought.mayavi.core.common import error
>
>
> from mayavi import mlab
> from mayavi.core.ui.api import MlabSceneModel, SceneEditor
> from mayavi.core.api import PipelineBase
> from tvtk.pyface.api import Scene
> from scipy.interpolate import griddata
>
>
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
>


--
Pietro Berkes
Scientific software developer
Enthought UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.enthought.com/pipermail/enthought-dev/attachments/20130304/9c5e9c85/attachment-0001.html

------------------------------

Message: 5
Date: Mon, 4 Mar 2013 10:31:05 -0500
From: Roan LaPlante <[hidden email]>
Subject: Re: [Enthought-Dev] Changing the index mapper on a
        pre-existing plot
To: [hidden email]
Message-ID:
        <CANXJ4aqzX6ze3EtF8vksp9eC1YVMHv8gUrg5Tp34_=[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Actually, I apologize.  I tried to give a solution for code I wrote a month
ago, and I forgot what I had done, and my previous email suggests a wrong
answer.  I ran into the same or a similar issue as you did; the size of the
data bounds being plotted changes, and the mapper displays the wrong size.
My program does recreate the axes every iteration of the data changing, but
this is because the axis extends LabelAxis to display labels in specific
colors that depend on the data.

The thing that does update the data bounds in my application is not
recreating the axes, but actually recreating and replacing the entire plot,
which was okay in my application.

This function is called within __init__ and whenever the data is updated
(ColorAxis and ConnmatPanClickTool extend LabelAxis and PanTool,
respectively)

def chaco_gen(self):
        # set the diagonal of the adjmat to lower threshold rather than 0
        # otherwise the color scheme is a mess for non-sparse matrices
        self.conn_mat = Plot(ArrayPlotData(imagedata=self.adj_thresdiag))
        self.conn_mat.img_plot("imagedata",name='conmatplot',
            colormap=cmap_reverse(RdYlBu))
        self.conn_mat.tools.append(ZoomTool(self.conn_mat))
        self.conn_mat.tools.append(ConnmatPanClickTool(self,self.conn_mat))
        self.xa=color_axis.ColorfulAxis(self.conn_mat,self.node_colors,'x')
        self.ya=color_axis.ColorfulAxis(self.conn_mat,self.node_colors,'y')
        self.conn_mat.underlays=[self.xa,self.ya]


Sorry if its not as much help as I thought it would be.

R

On Fri, Mar 1, 2013 at 9:38 PM, Adam Hughes <[hidden email]> wrote:

> Do you do this with a call to PlotAxis?  Can you post an snippet from your
> code if you get a chance?
>
> Thanks
>
>
> On Fri, Mar 1, 2013 at 9:37 PM, Roan LaPlante <
> [hidden email]> wrote:
>
>> I am not sure of the "best" way of doing it, but I found one of the
>> easiest ways for dealing with changing the data bounds in my program was
>> not to change the mapper but to discard and recreate the axis, which was
>> very quick.
>>
>> R
>>
>> On Fri, Mar 1, 2013 at 7:12 PM, Adam Hughes <[hidden email]>wrote:
>>
>>> I have a chaco Plot() which updates many of its components (LabelAxis,
>>> plot.plots etc...) dynamically in response to user interaction.  One thing
>>> I noticed is that the index_mapper and value_mapper attributes of Plot()
>>> are set upon initialization, and don't appear to automatically update when
>>> line plots are added, removed or changed.  As such, my range_selection tool
>>> still maps the indicies of the original plot index.
>>>
>>> I've tried to update the mapper upon changes to the plot.plots list.
>>>  Witthout getting into the code, suffice to say it is not behaving as
>>> expected.  This also has to do with me not quite understanding the deep
>>> relations between LinearMapper, DataRange1D and ArrayDataSource.  In any
>>> case, I wondered if there was a prescribed method for doing this?  EG, does
>>> Plot, or LinearMapper or some other class have a method the purpose of
>>> which is to do what I'm describing.  I saw that there are several "refresh
>>> methods" but can't quite get my head around them entirely.
>>>
>>> The implementation below works, but doesn't give me correct values for
>>> the range selection after I change the index.  The index is literally the
>>> index values of a dataframe.
>>>
>>>     def _update_rangeselect(self):
>>>         ''' Overwrites range selection tool in current plot.'''
>>>
>>>         #### Remove current overlay
>>>         self.plot.overlays=[obj for obj in self.plot.overlays if not
>>> isinstance(obj, RangeSelectionOverlay)]
>>>
>>>         mycomp=self.plot.plots.itervalues().next()[0] #Quick wayt to get
>>> first value in dictionary
>>>
>>>         inds=range(len(self.df.index))
>>>         idx=ArrayDataSource(inds)
>>>         vals=ArrayDataSource(df.index.values)
>>>
>>>         index_range = DataRange1D(idx)
>>>         val_range=DataRange1D(vals)
>>>         imap=LinearMapper(range=index_range)
>>>         vmap=LinearMapper(range=val_range)
>>>
>>>         mycomp.index_mapper=imap
>>>         mycomp.value_mapper=vmap
>>>
>>>         self.rangeselect=RangeSelection(mycomp, axis=self.selection_axis)
>>>         self.plot.active_tool = self.rangeselect
>>>
>>> self.plot.overlays.append(RangeSelectionOverlay(component=mycomp))
>>>         self.rangeselect.on_trait_change(self.on_selection_changed,
>>> "selection")
>>>
>>> --
>>> Adam Hughes
>>> Physics Ph.D Candidate
>>> George Washington University
>>>
>>> _______________________________________________
>>> Enthought-Dev mailing list
>>> [hidden email]
>>> https://mail.enthought.com/mailman/listinfo/enthought-dev
>>>
>>>
>>> The information in this e-mail is intended only for the person to whom
>>> it is
>>> addressed. If you believe this e-mail was sent to you in error and the
>>> e-mail
>>> contains patient information, please contact the Partners Compliance
>>> HelpLine at
>>> http://www.partners.org/complianceline . If the e-mail was sent to you
>>> in error
>>> but does not contain patient information, please contact the sender and
>>> properly
>>> dispose of the e-mail.
>>>
>>>
>>
>>
>> --
>> Roan LaPlante
>> Athinoula A. Martinos Center for Biomedical Imaging
>>
>>
>> _______________________________________________
>> Enthought-Dev mailing list
>> [hidden email]
>> https://mail.enthought.com/mailman/listinfo/enthought-dev
>>
>>
>
>
> --
> Adam Hughes
> Physics Ph.D Candidate
> George Washington University
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.enthought.com/pipermail/enthought-dev/attachments/20130304/c714b16e/attachment.html

------------------------------

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


End of Enthought-Dev Digest, Vol 103, Issue 3
*********************************************


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

Re: pyinstaller + no module named pyface.ui

_jelle_
PyInstaller is really pretty cool, though its too bad that no hook is provided
for the traits modules. Anyway, true, its all about getting around those hidden
imports. Its critical to understand this, since its really the key to packaging
with PyInstaller. Traits(ui) and PyFace perform quite a bit of magic behind the
scenes  such to abstract the toolkits. as such and due to python's highly
dynamic character its sometimes impossible to trace the imports.

Now, the way to go about this is first to make a .spec file and then you're
able to add additional hidden imports.  This spec is just python code and allows
for easy inclusion of datafiles too.

The better way to go about this is to write a custom hook [1].
I think kyvi [2] is an interesting reference to provide pyinstaller
support. Would that be an interesting contribution?

a = Analysis(['../main.py'],
             pathex=['../Code/PyRAPID'],
             hiddenimports=[""your_hidden_modules"],
             hookspath=None,
             runtime_hooks=None)

[1] http://goo.gl/hoK3a

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev