abetlen / abetlen/llama-cpp-python

Module import doesn't work when using pip install llama-cpp-python --target="dir"

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

描述

When using the latest update with how I've setup my embedded install, I ran into this issue:
```
No module named 'llama_cpp.llama_chat_format'
Traceback (most recent call last):
File "Z:\Anyboty_Client\llamacppClient.py", line 252, in
llama_cpp = importlib.import_module(llama_module_dir, package="llama_cpp") # Import the llama module from the llama-cpp-python module
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "Z:\Anyboty_Client\PythonFiles\llama_cpp_versions\12_1\ggufv2\windows10\llama_cpp\__init__.py", line 2, in
from .llama import *
File "Z:\Anyboty_Client\PythonFiles\llama_cpp_versions\12_1\ggufv2\windows10\llama_cpp\llama.py", line 27, in
import llama_cpp.llama_chat_format as llama_chat_format
ModuleNotFoundError: No module named 'llama_cpp.llama_chat_format'
```

I resolved the issue in my specific setup by changing this:
https://github.com/abetlen/llama-cpp-python/blob/01846a76b980224609ac8b69c8eb3f5785816752/llama_cpp/llama.py#L26-L27

To this:
```
from . import llama_cpp
from . import llama_chat_format
```

And while I think this is probably a fine solution, not 100% sure. So thought I'd just bring it to y'alls attention and let you fix it properly.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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