Search code examples
pythonplaywright

Python executable packaged with auto-py-to-exe is missing files from a dependancy


I'm getting the following error when trying to run an executable. The program uses the browserforge library.

C:\Users\jacob\Documents\output>main.exe
browser-helper-file.json ----------------------------------------   0% 0/? bytes ?
header-network.json      ----------------------------------------   0% 0/? bytes ?
headers-order.json       ----------------------------------------   0% 0/? bytes ?
input-network.json       ----------------------------------------   0% 0/? bytes ?
fingerprint-network.json ----------------------------------------   0% 0/? bytes ?
Traceback (most recent call last):
  File "main.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "browserforge\injectors\__init__.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "browserforge\injectors\utils.py", line 8, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "browserforge\fingerprints\__init__.py", line 3, in <module>
  File "browserforge\download.py", line 159, in DownloadIfNotExists
  File "browserforge\download.py", line 150, in Download
  File "asyncio\runners.py", line 194, in run
  File "asyncio\runners.py", line 118, in run
  File "asyncio\base_events.py", line 687, in run_until_complete
  File "browserforge\download.py", line 145, in AsyncDownload
  File "browserforge\download.py", line 137, in download
  File "browserforge\download.py", line 111, in _download_and_extract
  File "browserforge\download.py", line 75, in _download_file
  File "aiofiles\base.py", line 63, in __aenter__
  File "aiofiles\base.py", line 59, in __await__
  File "aiofiles\threadpool\__init__.py", line 92, in _open
  File "concurrent\futures\thread.py", line 58, in run
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\jacob\\AppData\\Local\\Temp\\_MEI64042\\browserforge\\headers\\data\\browser-helper-file.json'
[PYI-7868:ERROR] Failed to execute script 'main' due to unhandled exception!

I've tried including the missing file through auto-py-to-exe, but that had no effect. I've made sure all libraries are installed in the virtual environment and I'm running auto-py-to-exe in the virtual environment as well. How do I ensure the executable includes the files used by browserforge?


Solution

  • I managed to solve the issue. In auto-py-to-exe include browserforge under "--collect-data".