0

I am trying to create an executable (exe) file using PyInstaller library for my code that uses eel.

EDIT: I fix that issue by reinstalling pyinstaller

I did not receive any errors while building the exe file using the command "python -m eel main.py web", only warnings. But when I try to start the exe file, it starts slow in the console and then opens the web page in Chrome. While console behind is open, the python functions works in web page, but the console closes after a few seconds later and all python connection is break. The console log from page returns "WebSocket is already in CLOSING or CLOSED state"

Ps. All code works perfectly in Pycharm

Python:

import eel
import sys
import platform

eel.init('web', allowed_extensions=['.js', '.html'])  # Give folder containing web files


@eel.expose  # Expose this function to Javascript
def py_test():
    eel.createAlert("test")
    print('test')
    return

if __name__ == '__main__':
    if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10:
        eel.start('main.html', mode='chrome', size=(1500, 1000))
    else:
        raise EnvironmentError('Error: System is not Windows 10 or above')

Html:

<!DOCTYPE html>
<html>

<head>
  <style>
    button {
      width: 500px;
      height: 500px;
    }
  </style>
  <script type="text/javascript" src="/eel.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
    $(document).ready(function () {
      $("#teste").click(function () {
        eel.py_test()();
        console.log("exec py func")
      });
    });

    // Create alert
    eel.expose(createAlert);
    function createAlert(msg) {
      console.log("print alert")
      alert(msg);
    }
  </script>
  <title>Gerador de Ngeren</title>
</head>

<body>
  <button id="teste">Gerar registros</button>
</body>

</html>

My cmd log to pyinstaller script:


C:\Users\USER\OneDrive\BKP\NEWG\GERADOR>python -m eel main.py web
Building executable with main script 'main.py' and web folder 'web'...

Running:
pyinstaller main.py --hidden-import bottle_websocket --add-data C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\eel\eel.js;eel --add-data web;web

1179 INFO: PyInstaller: 5.6.2
1179 INFO: Python: 3.9.7
1213 INFO: Platform: Windows-10-10.0.19044-SP0
1216 INFO: wrote C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\main.spec
2171 INFO: UPX is available.
2174 INFO: Extending PYTHONPATH with paths
['C:\\Users\\USER\\OneDrive\\BKP\\NEWG\\GERADOR',
 'C:\\Users\\USER\\OneDrive\\BKP\\NEWG\\GERADOR']
3678 INFO: checking Analysis
3678 INFO: Building Analysis because Analysis-00.toc is non existent
3678 INFO: Initializing module dependency graph...
3683 INFO: Caching module graph hooks...
3711 INFO: Analyzing base_library.zip ...
7035 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
7037 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib'
10210 INFO: Caching module dependency graph...
10379 INFO: running Analysis Analysis-00.toc
10396 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\USER\AppData\Local\Programs\Python\Python39\python.exe
10445 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of C:\Users\USER\AppData\Local\Programs\Python\Python39\python39.dll
10626 INFO: Analyzing C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\main.py
14528 INFO: Analyzing hidden import 'bottle_websocket'
14805 INFO: Processing module hooks...
14805 INFO: Loading module hook 'hook-eel.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
14814 INFO: Loading module hook 'hook-jinja2.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
14816 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
14821 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
14823 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
14824 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
14960 INFO: Loading module hook 'hook-gevent.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
15584 INFO: Determining a mapping of distributions to packages...
66589 WARNING: Unable to find package for requirement zope.interface from package gevent.
66589 WARNING: Unable to find package for requirement zope.event from package gevent.
66590 INFO: Packages required by gevent:
['greenlet', 'cffi', 'setuptools']
68296 INFO: Processing pre-find module path hook site from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
68298 INFO: site: retargeting to fake-dir 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\fake-modules'
69100 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
69103 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
69158 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
69161 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
69164 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
70166 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
71184 WARNING: Hidden import "pkg_resources.py2_warn" not found!
71347 WARNING: Hidden import "pkg_resources.markers" not found!
71351 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
71353 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76574 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76575 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76576 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76696 INFO: Loading module hook 'hook-zope.interface.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76699 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
76929 INFO: checking Tree
76929 INFO: Building Tree because Tree-00.toc is non existent
76930 INFO: Building Tree Tree-00.toc
77019 INFO: checking Tree
77019 INFO: Building Tree because Tree-01.toc is non existent
77021 INFO: Building Tree Tree-01.toc
77146 INFO: checking Tree
77148 INFO: Building Tree because Tree-02.toc is non existent
77149 INFO: Building Tree Tree-02.toc
77154 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
77156 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
77830 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
78475 INFO: Loading module hook 'hook-win32com.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
79277 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
79361 INFO: Import to be excluded not found: 'f2py'
79385 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
79389 INFO: Loading module hook 'hook-packaging.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
79392 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks'...
79436 INFO: Looking for ctypes DLLs
79584 INFO: Analyzing run-time hooks ...
79591 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
79593 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
79597 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
79598 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
79606 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32api.py'
79608 INFO: Including run-time hook 'C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'
79623 INFO: Looking for dynamic libraries
80132 INFO: Looking for eggs
80132 INFO: Using Python library C:\Users\USER\AppData\Local\Programs\Python\Python39\python39.dll
80133 INFO: Found binding redirects:
[]
80140 INFO: Warnings written to C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\build\main\warn-main.txt
80237 INFO: Graph cross-reference written to C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\build\main\xref-main.html
80257 INFO: Appending 'datas' from .spec
80262 INFO: checking PYZ
80262 INFO: Building PYZ because PYZ-00.toc is non existent
80262 INFO: Building PYZ (ZlibArchive) C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\build\main\PYZ-00.pyz
81345 INFO: Building PYZ (ZlibArchive) C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\build\main\PYZ-00.pyz completed successfully.
81368 INFO: checking PKG
81368 INFO: Building PKG because PKG-00.toc is non existent
81368 INFO: Building PKG (CArchive) PKG-00.pkg
81436 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
81438 INFO: Bootloader C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
81438 INFO: checking EXE
81438 INFO: Building EXE because EXE-00.toc is non existent
81439 INFO: Building EXE from EXE-00.toc
81442 INFO: Copying icons from ['C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
82116 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
82116 INFO: Writing RT_ICON 1 resource with 3752 bytes
82117 INFO: Writing RT_ICON 2 resource with 2216 bytes
82117 INFO: Writing RT_ICON 3 resource with 1384 bytes
82118 INFO: Writing RT_ICON 4 resource with 37019 bytes
82118 INFO: Writing RT_ICON 5 resource with 9640 bytes
82118 INFO: Writing RT_ICON 6 resource with 4264 bytes
82119 INFO: Writing RT_ICON 7 resource with 1128 bytes
82184 INFO: Appending archive to EXE C:\Users\USER\OneDrive\BKP\NEWG\GERADOR\build\main\main.exe
84170 INFO: Building EXE from EXE-00.toc completed successfully.
84173 INFO: checking COLLECT
84174 INFO: Building COLLECT because COLLECT-00.toc is non existent
84175 INFO: Building COLLECT COLLECT-00.toc
85929 INFO: Building COLLECT COLLECT-00.toc completed successfully.

C:\Users\USER\OneDrive\BKP\NEWG\GERADOR>

Any tips to resolve this?

golfinLP
  • 1
  • 1
  • @СергейКох I don't believe that the code from either script is necessary, as the code works in the IDE. This issue pertains to using the PyInstaller method on Eel scripts. – golfinLP Feb 08 '23 at 21:25
  • how do you expect anyone to be able to help debug the issue if you don't provide your code or a [mre] that produces the same issue? – Alexander Feb 09 '23 at 03:53

0 Answers0