abetlen / abetlen/llama-cpp-python

Pyinstaller Cannot Find File After Compiling

未關閉
#1,565 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
10.6k
分支
1.4k
PR 合併指標
PR 指標待擷取

描述

# Prerequisites
- I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- I carefully followed the [README.md](https://github.com/abetlen/llama-cpp-python/blob/main/README.md).
- I [searched using keywords relevant to my issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/filtering-and-searching-issues-and-pull-requests) to make sure that I am creating a new issue that is not already open (or closed).
-I reviewed the [Discussions](https://github.com/abetlen/llama-cpp-python/discussions), and have a new bug or useful enhancement to share.

# Expected Behavior
I am confident that llama-cpp-python shouldn't act like this after being converted to an executable. I expect the file to properly locate the necessary files after the executable is run.

# Current Behavior
After compiling my FastAPI backend to an executable (uses llama-cpp-python as a dependency) I try to run the executable, I am met with the following error:
Traceback (most recent call last):
File "main.py", line 12, in
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "llama_cpp\__init__.py", line 1, in
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "llama_cpp\llama_cpp.py", line 83, in
File "llama_cpp\llama_cpp.py", line 57, in _load_shared_library
File "", line 1125, in add_dll_directory
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\NATHAN~1\\AppData\\Local\\Temp\\_MEI253282\\llama_cpp'
[23408] Failed to execute script 'main' due to unhandled exception!

In the first place, there is no AppData directory on my machine, and there is no NATHAN~1 user on my machine.

# Environment and Context
I am using an Anaconda environment on Windows, I don't think that the other dependencies are causing this bug, it's probably got something to do with how the python bindings load the llama_cpp dependency, which is loaded on installation of the module.
* Physical Windows 11

```
$ python3 --version
3.12.3
```

# Steps to Reproduce

Please provide detailed steps for reproducing the issue. We are not sitting in front of your screen, so the more detail the better.

1. Create a python file that uses llama-cpp-python
2. Convert the python file to an executable with pyinstaller example.py
3. Run the executable in the dist folder

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。