[Python] Creating an exe from a streamlit app using pyinstaller

Discussão em 'Python' iniciado por Stack, Junho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am creating a exe of a streamlit app my webpage shows "Error 403 Forbidden" when I try to run the EXE when the webpage launches. Do you have any suggestions how to fix the issues with streamlit and the EXE app. I am trying to create an exe app that allows anyone to run it with out having knowledge on how to install python libraries.

    I created the following spec file.

    from PyInstaller.utils.hooks import copy_metadata, get_package_paths
    import os

    datas = []
    datas += copy_metadata('streamlit')

    datas += ('Picking.py', '.'), ('helper.py', '.'), ('LOGO.PNG', '.')

    streamlit_path = get_package_paths('streamlit')[1]
    for folder in ['static', 'runtime', 'web', 'config', 'components']:
    full_path = os.path.join(streamlit_path, folder)
    if os.path.exists(full_path):
    for root, _, files in os.walk(full_path):
    for file in files:
    src = os.path.join(root, file)
    rel_path = os.path.relpath(src, streamlit_path)
    datas.append((src, os.path.join('streamlit', rel_path)))


    a = Analysis(
    ['execute_app.py'],
    pathex=[],
    binaries=[],
    datas=datas,
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
    )

    pyz = PYZ(a.pure)

    exe = EXE(pyz,
    a.scripts,
    a.binaries,
    a.datas,[],
    name='execute_app',
    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
    )

    coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='execute_app'
    )


    Here are the libraries I used

    • streamlit
    • pandas
    • numpy
    • matplotlib
    • network
    • plotly
    • pyvis
    • zipfile

    Inside C:\Users<User>.streamlit, i added the config.toml file with the following information.

    [theme]
    base="light"
    primaryColor="#FFC700" # Bright Yellow
    backgroundColor="#ffffff" # White background
    secondaryBackgroundColor="#f0f2f6" # Light Gray
    textColor="#333333" # Dark Gray
    font="sans serif"

    [server]
    maxUploadSize = 1000 # Increase this limit if necessary (in MB)
    enableXsrfProtection = true
    enableCORS = true

    [global]
    developmentMode = false

    Continue reading...

Compartilhe esta Página