Search code examples
python-3.xpyinstallerflask-socketio

Why does PyInstaller fail to package eventlet?


I'm trying to make a companion app for elite dangerous to aid exploration. The bones of the code are down and now I'm trying to package up what is essentially a flask / socketio / flaskwebui app into a single .exe

When I issue the following command:

pipenv run pyinstaller EDScout-WebUI\WebUI.py

It appears to run successfully. However, when I try to run the resulting .exe I get:

C:\Users\Jon\Documents\EDScout\dist>WebUI
Traceback (most recent call last):
  File "EDScout-WebUI\WebUI.py", line 7, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "NavRouteForwarder.py", line 2, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\__init__.py", line 10, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\convenience.py", line 4, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\greenpool.py", line 4, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\queue.py", line 49, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\event.py", line 3, in <module>
  File "c:\users\jon\.virtualenvs\edscout-yes4e1p6\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\eventlet\hubs\__init__.py", line 19, in <module>
  File "site-packages\eventlet\hubs\__init__.py", line 19, in <genexpr>
  File "importlib\__init__.py", line 127, in import_module
ModuleNotFoundError: No module named 'eventlet.hubs.epolls'
[20936] Failed to execute script WebUI

Full source is available here: https://github.com/joncage/ed-scout/tree/0004-TurnIntoApp


Solution

  • Turned out I needed the following:

    pipenv run pyinstaller ^
        --hidden-import=eventlet.hubs.epolls ^
        --hidden-import=eventlet.hubs.kqueue ^
        --hidden-import=eventlet.hubs.selects ^
    

    as the following was not sufficient:

    pipenv run pyinstaller ^
        --hidden-import=eventlet