I am trying to package my python program using ‘gradio’ for the GUI and the custom gradio addon ‘gradio_rangeslider’ (by freddyaboulton on GitHub).
Previously I was unable to import gradio until I followed this thread (https://github.com/pyinstaller/pyinstaller/issues/8108). I added –collect-data=gradio and –collect-data=gradio_client to the command line argument and specified in the .spec file to import gradio as ‘py’ files.
i generated a .spec file by using: pyi-makespec --additional-hooks-dir="build_deps\" --collect-data=gradio_client --collect-data=gradio --hidden-import pyarrow.vendored.version --onefile Program_name.py
The .spec file is as follows
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files
datas = []
datas += collect_data_files('gradio_client')
datas += collect_data_files('gradio')
a = Analysis(
['Program_name.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=['pyarrow.vendored.version'],
hookspath=['build_deps\'],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
module_collection_mode={
'gradio': 'py',
},
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='Program_name',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
I then ran: pyinstaller --clean --noconfirm Program_name.spec
The .exe was constructed but when I run it i get the following error.
Traceback (most recent call last):
File "Program_name.py", line 22, in <module>
ModuleNotFoundError: No module named 'gradio_rangeslider'
[PYI-24644:ERROR] Failed to execute script 'Program_name' due to unhandled exception!
I have trieed adding –collect-data=gradio_rangeslider to the pyi-makespec command and setting gradio_rangeslider as ‘py’ compile mode in the .spec file.
module_collection_mode={
'gradio': 'py',
'gradio_rangeslider ': 'py'
},
But I still get the same error. I am unsure if this module is configured correctly, or if I am missing something. All modules are installed in a python virtual environment and pyinstaller is being run from within the virtual environment. The code runs file as a python file.
Any help with this would be appreciated.
EDIT: found this message in the pyinstaller CMD outputs WARNING: collect_data_files - skipping data collection for module 'gradio_rangeslider' as it is not a package.
I don’t know why it thinks its not a package.