Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen Anfängerfreundlich
#907 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
65/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
build-system

Rechercherichtung

Das Issue befindet sich in llama_cpp/llama.py in den Zeilen 26–27, wo ein Import bei der Installation mit --target fehlschlägt. Untersuche die Modulstruktur, um den korrekten Importpfad zu verstehen. Teste die Korrektur, indem du das Paket mit --target in einem temporären Verzeichnis installierst und überprüfst, ob der Import funktioniert. Prüfe, ob es in der Codebasis weitere ähnliche Importanweisungen gibt, die dieselbe Änderung benötigen könnten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug build

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 <module>
    llama_cpp = importlib.import_module(llama_module_dir, package="llama_cpp") # Import the llama module from the llama-cpp-python module
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", 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 <module>
    from .llama import *
  File "Z:\Anyboty_Client\PythonFiles\llama_cpp_versions\12_1\ggufv2\windows10\llama_cpp\llama.py", line 27, in <module>
    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.

Vorherrschende Sprache
Python
Sterne
10.6k
Forks
1.5k
Ø Merge
6 Std. 43 Min.
Gemergte PRs (30 T.)
2

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus abetlen/llama-cpp-python

Alle Issues in abetlen/llama-cpp-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.