Pysimplegui: Issue with frozen mutiprocessing script is ran

Created on 12 Sep 2018  路  41Comments  路  Source: PySimpleGUI/PySimpleGUI

Hi Mike,

I messaged you about this issue on reddit, although I have found my workaround for it, using threads instead for my task.
Maybe in the future it might affect the ability to distribute scripts made from your package.
As usual i did it in a venv, modules in attached text.

Using Windows 10 64bit, Python 3.6

requirements.txt

import PySimpleGUI as sg
import os, time
from concurrent.futures import ThreadPoolExecutor, as_completed
from multiprocessing import Process

def another_long_func():

    #this is the long func call, of course as of right now it is a progress bar, 
    #but in place of it should be a normal function and a popup to indicate that it is done

    for i in range(20):
        sg.EasyProgressMeter("In Process code", i+1, 20)
        time.sleep(0.5)

def func_to_do():

    #So initially this is where the progress bar would show up, the func call to the 
    #another_long_func has already been profiled for example to last 10 seconds

    p=Process(target=another_long_func)
    p.start()
    for i in range(20):
        sg.EasyProgressMeter("test", i+1, 20)
        time.sleep(0.5)
    p.join()


def StatusOutputExample_context_manager():
    with sg.FlexForm('Running Timer', auto_size_text=True) as form:
        output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20))
        form_rows = [[sg.Text('Non-blocking GUI with updates')],
                     [output_element],
                     [sg.SimpleButton('Quit')]]

        form.LayoutAndRead(form_rows, non_blocking=True)

        for i in range(1, 1000):
            output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
            button, values = form.ReadNonBlocking()
            if values is None or button == 'Quit':
                func_to_do()
                break
            time.sleep(.01)
        else:
            form.CloseNonBlockingForm()

def main():
    StatusOutputExample_context_manager()
    sg.MsgBox('End of non-blocking demonstration')
    # StatusOutputExample_context_manager()

if __name__ == '__main__':
    # 
    # freeze_support because the earlier bugs in PyInstaller have metioned that it is required
    # however as of 3.3 the docs officially state it is not needed, although it doesn't hurt.

    # script runs fine as .py file, but when you run the exe generated by 
    # pyinstaller test.py --onefile 

    # it ignores the process call and restarts the main process again...

    # 
    from multiprocessing import freeze_support
    freeze_support()
    main()
In progress help wanted

All 41 comments

I'm running Windows 10, 64 bit and only got crashes when I tried PyInstaller version 3.4

It seems to build OK, but I get this crash when I try and run the .exe

Would be AWESOME to get this to work. Then people could distribute .EXE files with a GUI!

Fatal Python error: Py_Initialize: unable to load the file system codec
LookupError: unknown encoding: utf-8

Current thread 0x00008fe0 (most recent call first):

I believe the issue maybe related to PyInstaller, I will work on this to see if i can modify your module to be copacetic with the build system. 馃憤

By the way this issue is non-existent with the following command:
pyinstaller test.py --onedir

hmm, maybe it will be the workaround, although it sucks. The issue revolves around how windows spawns processes in python.

PySimpleGUI.py is capable of running standalone. So, I typed this command:

pyinstaller pysimplegui.py --onedir

I still got the same error. And I still get a ton of info printed out when I do the build.

Really hopeful something's possible... this would be such a cool thing to be able to do!

A:\TEMP\a>pyinstaller pysimplegui.py --onedir
89 INFO: PyInstaller: 3.4
90 INFO: Python: 3.6.2
91 INFO: Platform: Windows-10-10.0.17134-SP0
94 INFO: wrote A:\TEMP\a\pysimplegui.spec
97 INFO: UPX is not available.
101 INFO: Extending PYTHONPATH with paths
['A:\\TEMP\\a', 'A:\\TEMP\\a']
104 INFO: checking Analysis
106 INFO: Building Analysis because Analysis-00.toc is non existent
107 INFO: Initializing module dependency graph...
123 INFO: Initializing module graph hooks...
129 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4756 INFO: running Analysis Analysis-00.toc
4770 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\anaconda3\python.exe
5302 INFO: Caching module hooks...
5306 INFO: Analyzing A:\TEMP\a\pysimplegui.py
5683 INFO: Loading module hooks...
5683 INFO: Loading module hook "hook-encodings.py"...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
5826 INFO: Loading module hook "hook-pydoc.py"...
5827 INFO: Loading module hook "hook-xml.py"...
6150 INFO: Loading module hook "hook-_tkinter.py"...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python\anaconda3\lib\tkinter\__init__.py", line 39, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
6438 ERROR: Tcl/Tk improperly installed on this system.
6451 INFO: Looking for ctypes DLLs
6451 INFO: Analyzing run-time hooks ...
6455 INFO: Including run-time hook 'pyi_rth__tkinter.py'
6460 INFO: Looking for dynamic libraries
6608 INFO: Looking for eggs
6609 INFO: Using Python library c:\python\anaconda3\python36.dll
6610 INFO: Found binding redirects:
[]
6613 INFO: Warnings written to A:\TEMP\a\build\pysimplegui\warn-pysimplegui.txt
6631 INFO: Graph cross-reference written to A:\TEMP\a\build\pysimplegui\xref-pysimplegui.html
6636 INFO: checking PYZ
6636 INFO: Building PYZ because PYZ-00.toc is non existent
6637 INFO: Building PYZ (ZlibArchive) A:\TEMP\a\build\pysimplegui\PYZ-00.pyz
7195 INFO: Building PYZ (ZlibArchive) A:\TEMP\a\build\pysimplegui\PYZ-00.pyz completed successfully.
7198 INFO: checking PKG
7198 INFO: Building PKG because PKG-00.toc is non existent
7199 INFO: Building PKG (CArchive) PKG-00.pkg
7267 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
7270 INFO: Bootloader c:\python\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
7270 INFO: checking EXE
7271 INFO: Building EXE because EXE-00.toc is non existent
7272 INFO: Building EXE from EXE-00.toc
7273 INFO: Appending archive to EXE A:\TEMP\a\build\pysimplegui\pysimplegui.exe
7277 INFO: Building EXE from EXE-00.toc completed successfully.
7279 INFO: checking COLLECT
7280 INFO: Building COLLECT because COLLECT-00.toc is non existent
7281 INFO: Building COLLECT COLLECT-00.toc
7471 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Hmm can you make a venv and then run the test? Pyinstaller is heavily reliant on patterned searches for files in modules, maybe your re package is corrupt?

Which package are you thinking is corrupt? I uninstalled and reinstalled Pyinstaller with --no-cache-dir. The problem remains. Are there other pip install options I should do in order to get a cleaner install?

I do not currently have a virtual environment set up. What would you recommend that I run in order to do this under Windows 10?

I would like something that will allow me to easily text Linux and test python 3.4.

it seems to be the re module

 File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):

I would try creating a small virtual environment for testing so that you can isolate the root cause. If you want i can upload my env and you can just run your tests on it.

@JorjMcKie managed to get a sample PySimpleGUI program built using nuitka!! 馃挴

I ran a PySimpleGUI.EXE file that he compiled. I've been unable to duplicate it using my setup. There are some tricky things to do in order to get tkinter working with nuitka.

If Jorj can work out the problems then we'll have an _amazing solution available for Windows users_!!! I'm SO looking forward to being able to give my Python programs to my friends that are not running Python. It opens up all sorts of opportunities

Nice! I've been eyeing that library too, did he give you a link to his build script?

It's happened!

@JorjMcKie and I have both compiled programs that use PySimpleGUI and they make an exe file (and folder full of stuff) that runs the program. I tried Pong as a performance and compat challenge and it worked perfectly!

Damn, this is a big damned deal. I'm working to get the instructions published.

Even if a nuitka solution is approaching,
I just want to note, that i'm using PySimpleGUI without any problems using pyinstaller (3.4).

"pyinstaller.exe script.py -w" using Windows 10 and Python3.7.0(Anaconda) creates in my casse a working exe file.

Awesome!
I wish I could join the fun and run with pyinstaller too.

I had not tried the -w flag. I tried it and managed to get a .EXE that didn't crash. It just didn't do anything at all.

I'm running Windows 10, anaconda 3.6.

Here is the build output

c:\Python\PycharmProjects\GooeyGUI\pyinstaller>pyinstaller pysimplegui.py -w
82 INFO: PyInstaller: 3.4
82 INFO: Python: 3.6.2
82 INFO: Platform: Windows-10-10.0.17134-SP0
84 INFO: wrote c:\Python\PycharmProjects\GooeyGUI\pyinstaller\pysimplegui.spec
86 INFO: UPX is not available.
92 INFO: Extending PYTHONPATH with paths
['c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller',
 'c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller']
92 INFO: checking Analysis
92 INFO: Building Analysis because Analysis-00.toc is non existent
92 INFO: Initializing module dependency graph...
100 INFO: Initializing module graph hooks...
102 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
3706 INFO: running Analysis Analysis-00.toc
3720 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\anaconda3\python.exe
4235 INFO: Caching module hooks...
4239 INFO: Analyzing c:\Python\PycharmProjects\GooeyGUI\pyinstaller\pysimplegui.py
4612 INFO: Loading module hooks...
4613 INFO: Loading module hook "hook-encodings.py"...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4746 INFO: Loading module hook "hook-pydoc.py"...
4748 INFO: Loading module hook "hook-xml.py"...
5031 INFO: Loading module hook "hook-_tkinter.py"...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python\anaconda3\lib\tkinter\__init__.py", line 39, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
5298 ERROR: Tcl/Tk improperly installed on this system.
5312 INFO: Looking for ctypes DLLs
5312 INFO: Analyzing run-time hooks ...
5315 INFO: Including run-time hook 'pyi_rth__tkinter.py'
5327 INFO: Looking for dynamic libraries
5476 INFO: Looking for eggs
5477 INFO: Using Python library c:\python\anaconda3\python36.dll
5477 INFO: Found binding redirects:
[]
5486 INFO: Warnings written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\pysimplegui\warn-pysimplegui.txt
5506 INFO: Graph cross-reference written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\pysimplegui\xref-pysimplegui.html
5514 INFO: checking PYZ
5514 INFO: Building PYZ because PYZ-00.toc is non existent
5514 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\pysimplegui\PYZ-00.pyz
6066 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\pysimplegui\PYZ-00.pyz completed successfully.
6072 INFO: checking PKG
6072 INFO: Building PKG because PKG-00.toc is non existent
6072 INFO: Building PKG (CArchive) PKG-00.pkg
6147 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
6150 INFO: Bootloader c:\python\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
6150 INFO: checking EXE
6151 INFO: Building EXE because EXE-00.toc is non existent
6151 INFO: Building EXE from EXE-00.toc
6153 INFO: Appending archive to EXE c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\pysimplegui\pysimplegui.exe
6157 INFO: Building EXE from EXE-00.toc completed successfully.
6161 INFO: checking COLLECT
6162 INFO: Building COLLECT because COLLECT-00.toc is non existent
6163 INFO: Building COLLECT COLLECT-00.toc
6485 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Did you try the -F option (creating only one .exe file)?

But it sounds more like an issue with your Python installation.
Du you have the deprecated enum-backport/enum34 package installed?

Otherwise you could try to update your python to 3.6.5 or 3.7.0 via conda and create a clean conda env.

@MrSunday334 have you tried to do it as onefile??

Yes, this works also without problems (under windows10 /py3.7) using only one file, although it needs ~2 seconds to start.

I have noticed that the program crashes if I build it with python3.6.6 instead of 3.7.0. But this may be a problem of my environment. But also in this case, the packing itself is without problems.

On Linux(Fedora/Gnome/Wayland), the software crashes regardless if I build a executable or not, as soon as the second window should be shown.

I'm currently running 3.6.2.

Perhaps this explains my crashing??

I have not tried the -F option.

While I'm running Conda, I never change my environment.

Part of my feet dragging is that I fear messing up the environment that's taken many months to get right.

I am unsure how to upgrade my Python in general. Can someone give me some advice?

Tried -F and -F -w. -F alone gave me the same "crash" as I had before.

Running with -F and -w did nothing but return to the command prompt after a couple seconds.

I feel like I'm getting "close" would be awesome to get this to work... just plain awesome

You can either create a new conda environment via PyCharm or the console.

To create a python3.7 environment the command would be conda create -n envname python=3.7
You can update components (including python) with conda update -n envname packagename

In most cases, I manage my environment via pycharm, but as anacondas main package ist only released for 3.6, I go with the console to create a Python 3.7 environment. But you can also go with python3.6 after I fixed the dependencies for pyinstaller it also runs flawless in python3.6.5 .

Best practice is to create a new environment (via pip or conda) for each project.
with conda list or conda list -n envname you can see which packages are currently installed.

In the best case you only have the packages you require in your environment.
As far as I see this would only be pyinstaller for the PSG, or do you have further dependencies, which I am missing?

so using the anaconda prompt:

conda create -n psg
conda activate psg
conda install pyinstaller
(python -m pip install PySimpleGUI) or using local codebase
pyinstaller test.py -wF
.\dist\test.exe

Will try these. Thank you for posting them and working on this.

Side note - I have been running the Nuitka compiled CPU Widget for over a day and it's rock solid. No errors, no memory leaks, pure .EXE bliss.

I'm dying to get PyInstaller working as another option. Running an EXE is SO cool. My skeptic non-Python programmers are sitting up and taking notice.

I entered all the nicely typed up Conda instructions.

I compiled a couple of different .py files and both had the same outcome. I get a bunch of stuff output during the built process. When I run the .EXE file, nothing happens except a spinning cursor for about seconds.

Here is the output from my build.


c:\Python\PycharmProjects\GooeyGUI\pyinstaller>pyinstaller Demo_All_Widgets.py -wF
86 INFO: PyInstaller: 3.4
86 INFO: Python: 3.6.2
87 INFO: Platform: Windows-10-10.0.17134-SP0
92 INFO: wrote c:\Python\PycharmProjects\GooeyGUI\pyinstaller\Demo_All_Widgets.spec
97 INFO: UPX is not available.
102 INFO: Extending PYTHONPATH with paths
['c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller',
 'c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller']
103 INFO: checking Analysis
104 INFO: Building Analysis because Analysis-00.toc is non existent
105 INFO: Initializing module dependency graph...
117 INFO: Initializing module graph hooks...
119 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
3764 INFO: running Analysis Analysis-00.toc
3777 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\anaconda3\python.exe
4285 INFO: Caching module hooks...
4297 INFO: Analyzing c:\Python\PycharmProjects\GooeyGUI\pyinstaller\Demo_All_Widgets.py
4673 INFO: Loading module hooks...
4673 INFO: Loading module hook "hook-encodings.py"...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4814 INFO: Loading module hook "hook-pydoc.py"...
4817 INFO: Loading module hook "hook-xml.py"...
5132 INFO: Loading module hook "hook-_tkinter.py"...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python\anaconda3\lib\tkinter\__init__.py", line 39, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
5410 ERROR: Tcl/Tk improperly installed on this system.
5426 INFO: Looking for ctypes DLLs
5426 INFO: Analyzing run-time hooks ...
5430 INFO: Including run-time hook 'pyi_rth__tkinter.py'
5436 INFO: Looking for dynamic libraries
5587 INFO: Looking for eggs
5587 INFO: Using Python library c:\python\anaconda3\python36.dll
5588 INFO: Found binding redirects:
[]
5593 INFO: Warnings written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\warn-Demo_All_Widgets.txt
5612 INFO: Graph cross-reference written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\xref-Demo_All_Widgets.html
5619 INFO: checking PYZ
5619 INFO: Building PYZ because PYZ-00.toc is non existent
5620 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\PYZ-00.pyz
6187 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\PYZ-00.pyz completed successfully.
6193 INFO: checking PKG
6193 INFO: Building PKG because PKG-00.toc is non existent
6195 INFO: Building PKG (CArchive) PKG-00.pkg
7958 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
7961 INFO: Bootloader c:\python\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
7968 INFO: checking EXE
7968 INFO: Building EXE because EXE-00.toc is non existent
7968 INFO: Building EXE from EXE-00.toc
7969 INFO: Appending archive to EXE c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist\Demo_All_Widgets.exe
7982 INFO: Building EXE from EXE-00.toc completed successfully.

Are you sure the newly created env is activated?
In this case, the prompt would read(psg) C:\Users\Mikeinstead of(base) C:\Users\Mike

I'm confused as it seems that anaconda tries to use the base environment and is also not updating python.

Can you enlist the output of "conda list" in your env?
It should be like:

(psg) C:\Users\Martin>conda list
packages in environment at C:\Anaconda3envs\psg:

Name Version Build Channel
altgraph 0.15 py_0 conda-forge
certifi 2018.8.24 py36_1
future 0.16.0 py36_2
macholib 1.11 py_0 conda-forge
pefile 2018.8.8 py_0 conda-forge
pip 10.0.1 py36_0
pycrypto 2.6.1 py36hfa6e2cd_9
pyinstaller 3.3.1 py36_vc14_0 [vc14] conda-forge
PySimpleGUI 3.3.0
python 3.6.6 hea74fb7_0
pywin32 223 py36hfa6e2cd_1
setuptools 40.2.0 py36_0
vc 14 h0510ff6_3
vs2015_runtime 14.0.25123 3
wheel 0.31.1 py36_0
wincertstore 0.2 py36h7fe50ca_0
zlib 1.2.11 vc14_0 [vc14] conda-forge

Further, you can try to update (inside your environment) conda update --all

Btw. you could test it in a VM, as its also working for me with fedora and ubuntu.

It's super weird that it worked for me right out-of-the box and I cant even reproduce this error.
For this particular error I found https://stackoverflow.com/a/45716067

@MrSunday334
Quick question, I know that OS determines how the subprocess call with be executed, but I have noticed on widows, when I call subprocess command with args I get an infinite loop of the first window popping up again even though it should be exited. Is this attributed to the os.fork method in windows?

Are you able to test on a windows os if you have a comp with it? I have tried it with different venvs by only going with the least required one. I would like to make sense of this before i try to distribute any apps. If i really have to upgrade to 3.7 to avoid those issues, lol i mean what the hell why not.

You are correct, the activate fails... I looked it up... I needed to do an activate psg

I had the same results unfortunately

c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>activate psg

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>conda activate psg

CommandNotFoundError: 'activate'


(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>conda install pyinstaller
Fetching package metadata .............

PackageNotFoundError: Packages missing in current channels:

  - pyinstaller

We have searched for the packages in the following channels:

  - https://repo.continuum.io/pkgs/main/win-64
  - https://repo.continuum.io/pkgs/main/noarch
  - https://repo.continuum.io/pkgs/free/win-64
  - https://repo.continuum.io/pkgs/free/noarch
  - https://repo.continuum.io/pkgs/r/win-64
  - https://repo.continuum.io/pkgs/r/noarch
  - https://repo.continuum.io/pkgs/pro/win-64
  - https://repo.continuum.io/pkgs/pro/noarch
  - https://repo.continuum.io/pkgs/msys2/win-64
  - https://repo.continuum.io/pkgs/msys2/noarch



(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>python -m pip install pysimplegui
Requirement already satisfied: pysimplegui in c:\python\anaconda3\lib\site-packages (3.5.1)

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>cd ..

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller>pyinstaller Demo_All_Widgets.py -wF
94 INFO: PyInstaller: 3.4
94 INFO: Python: 3.6.2
96 INFO: Platform: Windows-10-10.0.17134-SP0
100 INFO: wrote c:\Python\PycharmProjects\GooeyGUI\pyinstaller\Demo_All_Widgets.spec
105 INFO: UPX is not available.
112 INFO: Extending PYTHONPATH with paths
['c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller',
 'c:\\Python\\PycharmProjects\\GooeyGUI\\pyinstaller']
112 INFO: checking Analysis
113 INFO: Building Analysis because Analysis-00.toc is non existent
118 INFO: Initializing module dependency graph...
134 INFO: Initializing module graph hooks...
137 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4441 INFO: running Analysis Analysis-00.toc
4454 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\anaconda3\python.exe
4975 INFO: Caching module hooks...
4979 INFO: Analyzing c:\Python\PycharmProjects\GooeyGUI\pyinstaller\Demo_All_Widgets.py
5392 INFO: Loading module hooks...
5393 INFO: Loading module hook "hook-encodings.py"...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 13, in walk_packages
  File "c:\python\anaconda3\lib\pkgutil.py", line 127, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "c:\python\anaconda3\lib\pkgutil.py", line 146, in _iter_file_finder_modules
    import inspect
  File "c:\python\anaconda3\lib\inspect.py", line 41, in <module>
    import linecache
  File "c:\python\anaconda3\lib\linecache.py", line 11, in <module>
    import tokenize
  File "c:\python\anaconda3\lib\tokenize.py", line 33, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
5551 INFO: Loading module hook "hook-pydoc.py"...
5554 INFO: Loading module hook "hook-xml.py"...
5897 INFO: Loading module hook "hook-_tkinter.py"...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python\anaconda3\lib\tkinter\__init__.py", line 39, in <module>
    import re
  File "c:\python\anaconda3\lib\re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
6208 ERROR: Tcl/Tk improperly installed on this system.
6213 INFO: Looking for ctypes DLLs
6213 INFO: Analyzing run-time hooks ...
6215 INFO: Including run-time hook 'pyi_rth__tkinter.py'
6218 INFO: Looking for dynamic libraries
6366 INFO: Looking for eggs
6367 INFO: Using Python library c:\python\anaconda3\python36.dll
6367 INFO: Found binding redirects:
[]
6375 INFO: Warnings written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\warn-Demo_All_Widgets.txt
6396 INFO: Graph cross-reference written to c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\xref-Demo_All_Widgets.html
6403 INFO: checking PYZ
6403 INFO: Building PYZ because PYZ-00.toc is non existent
6403 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\PYZ-00.pyz
6975 INFO: Building PYZ (ZlibArchive) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\build\Demo_All_Widgets\PYZ-00.pyz completed successfully.
6981 INFO: checking PKG
6982 INFO: Building PKG because PKG-00.toc is non existent
6983 INFO: Building PKG (CArchive) PKG-00.pkg
8759 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
8762 INFO: Bootloader c:\python\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
8762 INFO: checking EXE
8763 INFO: Building EXE because EXE-00.toc is non existent
8763 INFO: Building EXE from EXE-00.toc
8763 INFO: Appending archive to EXE c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist\Demo_All_Widgets.exe
8773 INFO: Building EXE from EXE-00.toc completed successfully.

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller>cd dist

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>Demo_All_Widgets.exe

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>


Ah, yes, we got a little aside from the topic of the issue.

@MrSunday334
Quick question, I know that OS determines how the subprocess call with be executed, but I have noticed on widows, when I call subprocess command with args I get an infinite loop of the first window popping up again even though it should be exited. Is this attributed to the os.fork method in windows?

Not quete sure about the techical fallpits between the different os, espeacily not with freeze_support(), but the behavior should remain the same.

Are you able to test on a windows os if you have a comp with it? I have tried it with different venvs by only going with the least required one. I would like to make sense of this before i try to distribute any apps. If i really have to upgrade to 3.7 to avoid those issues, lol i mean what the hell why not.

The problems I had with 3.6 were self-made (no pyinstaller for 3.6 installed ... d'oh) so it works for me under Windows 10 without problems. If I hit cancel the second task pops up if not, the tasks ends, correct?
I got problems under linux but this is probably an other issue.

This works so far independent whether I pack it with pyinstaller or not.

Have you tried to create the env as I described before, under this configuration it's working for me?
maybe you can python -m pip install pyinstaller to get the 3.4 pyinstaller version, instead of 3.3 which is bundled in anaconda.

Perhaps this enum attribute error thing may be causing the problem? Do others get this same erro?

It shows I'm running Pyinstaller version 3.4
python -m pip install pyinstaller
Requirement already satisfied: pyinstaller in c:\python\anaconda3\lib\site-packages (3.4)
Requirement already satisfied: setuptools in c:\users\mike\appdata\roaming\python\python36\site-packages (from pyinstaller) (40.0.0)
Requirement already satisfied: pefile>=2017.8.1 in c:\python\anaconda3\lib\site-packages (from pyinstaller) (2018.8.8)
Requirement already satisfied: macholib>=1.8 in c:\python\anaconda3\lib\site-packages (from pyinstaller) (1.11)
Requirement already satisfied: altgraph in c:\python\anaconda3\lib\site-packages (from pyinstaller) (0.16.1)
Requirement already satisfied: pywin32-ctypes in c:\python\anaconda3\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: future in c:\python\anaconda3\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.16.0)

You are correct, the activate fails... I looked it up... I needed to do an activate psg

I had the same results unfortunately

ok, next try..

maybe you can try to install pyinstaller also via pip
python -m pip install pyinstaller
(and remove in doubt th anaconda version)
this gets you version 3.4 of pyinstaller.

Perhaps this enum attribute error thing may be causing the problem? Do others get this same error?

Yes, but it seems that there an deprecated enum34 module was installed

It's super weird that it worked for me right out-of-the box and I cant even reproduce this error.
For this particular error I found https://stackoverflow.com/a/45716067

What does conda listsay?

(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>
(psg) c:\Python\PycharmProjects\GooeyGUI\pyinstaller\dist>conda list
# packages in environment at C:\Python\Anaconda3\envs\psg:
#

no packages? Thats weird.
try to install pyinstaller and PSG via pip or conda

Otherwise try to call pyinstaller directly:
C:\Python\Anaconda3\envs\psg\Scripts\pyinstaller.exe -w file.py

I did the pip installs and they all say requirement met.

I uninstalled pysimplegui and reinstalled and the conda list was still empty

There is no exe in that folder... there is only .bat files

I did this and still bad looking output and exe did nothing
C:\Python\Anaconda3\Scripts\pyinstaller.exe -w Demo_All_Widgets.py

THIS IS SO FRUSTRATING

It's ALMOST as frustrating as trying to setup (and failing) a shared folder using VirtualBox

As long the error with the enum is there pyinstaller will not create a wellformed output. The question is why your environment is... special.

Is there a way to contact you more directly, than chatting in a Github issue?

sure! Email me and I'll give you my phone number.

My environment... SUCKS

of course my email is....
[email protected]

you can also get me at:
[email protected]

IT WORKS!!!

Thank you SO MUCH for the live help @MrSunday334 !

All I had to do was uninstall enum34 and it all suddenly works!

I created a single .EXE file for one of the demo programs and it was only 9 MB in total with only 1 file needed. THAT is amazing!

I cannot wait to document this!!!!

Now anyone can easily write a windows program with a GUI

pyinstaller -wF my_program.py

This is the magic line to enter to turn your PySimpleGUI program into a single .EXE file that you can distribute.

Are the instructions for creating a .exe from a PySimpleGUI based program really this simple?

Do these only once

Install PyInstaller

pip install pyinstaller

Install PySimpleGUI

pip install pysimplegui

Write your PySimpleGUI program

Use PyCharm or another IDE to create your GUI program
Test it out on Windows

Compile your program into a .EXE file

pyinstaller -wF yourprogram.py

yourprogram.exe will be in a subfolder named dist

Distribute your yourprogram.exe to anyone running windows

hmm I use a spec file, usually it depends on the dependencies you have within your script. So now that you can make the exe can you try the script that I put up early in the thread?

OK, I fixed up the code... it ran both as a.py and a .exe

One thing you cannot do is run more than 1 EasyProgressMeter at a time. This is why I wrote OneLineProgressMeter. But that's not the point of your post.

It worked great. I'll see if I can work it into the code that is causing my multi-threaded crash.

You rock dude! I would like to certainly learn from you how did you decide to structure your lib?

Thanks for the compliment! I'll take all of those I can get!

how did you decide to structure your lib?

Structure which part? The overall structure is a _mess_ in my opinion. The .py file is now > 4800 lines of code.

When I started, a few months ago, I was learning Python. PySimpleGUI was one of my first programs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flowerbug picture flowerbug  路  4Comments

eyeonus picture eyeonus  路  6Comments

thelou1s picture thelou1s  路  4Comments

MikeTheWatchGuy picture MikeTheWatchGuy  路  3Comments

ECOM-Klaus picture ECOM-Klaus  路  4Comments