Search code examples
pyinstallerexellama

Making an exe of a llama index application


I got a strange error when tying to build an exe using pyinstaller. Im using a conda virtual environment, and smaller apps compile ok. However it is giving me an error:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\me\AppData\Local\Temp\_MEI140402\llama_index\VERSION'

The strange thing about it is that the program runs all okay on my system, and I'm having many issues making this exe. When I run locally there is no file like this in the temp folder.

Are there any other options to distribute my code?

# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['run.py'],
    pathex=[ all extra paths ],
    binaries=[],
    datas=[('added_hook.py', '.'),
    ],
    hiddenimports=['docmaker'],
    hookspath=['all hooks' ],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='run',
    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.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='run',
)

I added all paths to my pathex so pyinstaller would pick it up, even the temp folder.

Also i added a py file called added_hook.py that adds more resources with the code. I attempted this to make sure pyinstaller would collect more files to compile the .exe

from PyInstaller.utils.hooks import collect_data_files

Instruct PyInstaller to collect data files from the 'resources' package.

datas = collect_data_files('resources')


Solution

  • Having the same problem. The file that is missing is in the llama_index/ package install directory itself. Not sure how to get this file included via pyinstaller

    Nasty hack that works for me: (but then blows up thinking transformers isn't installed...)

    datas += [('.venv/lib/python3.11/site-packages/llama_index/VERSION', 'llama_index/')]