Program in python doesn't work after packaging with pyinstaller Program in python doesn't work after packaging with pyinstaller tkinter tkinter

Program in python doesn't work after packaging with pyinstaller


So are you still struggling with this?

You would need to update your spec file's "data" and "hiddenimports" section to ensure the libraries are imported across. I've shown you mine below (it works just fine). You need to modify it to include openpyxl, tkinter and pandas.

a = Analysis(['main.py'],             pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],             binaries=[],             datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],             hiddenimports=['pandas','numpy','plotly','pptx'],             hookspath=[],             runtime_hooks=[],             excludes=[],             win_no_prefer_redirects=False,             win_private_assemblies=False,             cipher=block_cipher,             noarchive=False)

I actually got the same error as you regarding plotly.json so I know the above solution works. :)

It's also important that if you're doing static image export - that you include either Kaleido or Orcas in the spec file. I'm using Kaleido so you can see it in my spec file setup.

Then run PyInstaller via:pyinstaller main.spec --clean

Where main.spec is your spec file (change the name).

EDIT:To make things easier, here's my entire spec file:

# -*- mode: python ; coding: utf-8 -*-# Command to compile the spec and python files# pyinstaller main.spec --clean --onefileblock_cipher = Nonea = Analysis(['main.py'],             pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],             binaries=[],             datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],             hiddenimports=['pandas','numpy','plotly','pptx'],             hookspath=[],             runtime_hooks=[],             excludes=[],             win_no_prefer_redirects=False,             win_private_assemblies=False,             cipher=block_cipher,             noarchive=False)pyz = PYZ(a.pure, a.zipped_data,             cipher=block_cipher)exe = EXE(pyz,          a.scripts,          [],          exclude_binaries=True,          name='main',          debug=False,          bootloader_ignore_signals=False,          strip=False,          upx=True,          console=True )coll = COLLECT(exe,               a.binaries,               a.zipfiles,               a.datas,               strip=False,               upx=True,               upx_exclude=[],               name='main')