Error converting GUI to standalone executable using Py2exe
Question: I am using `py2exe` to convert my program with multiple GUIs to a standalone
executable. I used PyQt to create the GUIs. The main script I run instantiates
the main UI, which contains buttons, tabs, etc. that can open sub-UIs. The
main script is `main_ui.py`.

I followed the tutorial on how to use `py2exe`, so I have the following
`setup.py`:

    
    
    from distutils.core import setup
    import py2exe
    
    setup(windows=['main_ui.py'])
    

Then, in the CMD: `> python setup.py py2exe`.

I tried creating a practice exe with a simple script and everything worked.
However, I got an error when I tried creating the exe from `main_ui.py`.

Here is the output:

    
    
    L:\internal\(path)>python setup.py py2exe
    running py2exe
    creating L:\internal\(path)\build
    creating L:\internal\(path)\build\bdist.win32
    creating L:\internal\(path)\build\bdist.win32\winexe
    creating L:\internal\(path)\build\bdist.win32\winexe\collect-2.7
    creating L:\internal\(path)\build\bdist.win32\winexe\bundle-2.7
    creating L:\internal\(path)\build\bdist.win32\winexe\temp
    creating L:\internal\(path)\dist
    *** searching for required modules ***
    error: compiling 'C:\Python27\lib\site-packages\PyQt4\uic\port_v3\proxy_base.py' failed
    SyntaxError: invalid syntax <proxy_base.py, line 26>
    

Here's `proxy_base.py`:

    
    
    from PyQt4.uic.Compiler.proxy_metaclass import ProxyMetaclass
    
    
    class ProxyBase(metaclass=ProxyMetaclass):
    """ A base class for proxies using Python v3 syntax for setting the
    meta-class.
    """
    

This came with PyQt4; does anyone know what's going on? Is this the right way
to make my program into an executable?


Answer: I have encountered the same problem. There is very probably a better way, but
removing the folder "PyQt4\uic\port_v3" solves the issue.

(see <http://python.6.x6.nabble.com/PyQt-4-7-and-py2exe-error-td1922933.html>)

