Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'kag' #96

Closed
AIREBA1 opened this issue Dec 4, 2024 · 6 comments
Closed

ModuleNotFoundError: No module named 'kag' #96

AIREBA1 opened this issue Dec 4, 2024 · 6 comments

Comments

@AIREBA1
Copy link

AIREBA1 commented Dec 4, 2024

问题报错源自于D:\xxx\kagdemo\Lib\site-packages\knext\command\sub_command\project.py
报错行来自于53行的import kag.templates.project

def _render_template(namespace: str, tmpl: str, **kwargs):
config_path = kwargs.get("config_path", None)
project_dir = Path(namespace)
if not project_dir.exists():
project_dir.mkdir()

import kag.templates.project--------------------------------------------------------这里

src = Path(kag.templates.project.__path__[0])
copytree(
    src,
    project_dir.resolve(),
    namespace=namespace,
    root=namespace,
    tmpl=tmpl,
    **kwargs,
)

import kag.templates.schema

src = Path(kag.templates.schema.__path__[0]) / f"{{{{{tmpl}}}}}.schema.tmpl"
if not src.exists():
    click.secho(
        f"ERROR: No such schema template: {tmpl}.schema.tmpl",
        fg="bright_red",
    )
dst = project_dir.resolve() / "schema" / f"{{{{{tmpl}}}}}.schema.tmpl"
copyfile(src, dst, namespace=namespace, **{tmpl: namespace})

tmpls = [tmpl, "default"] if tmpl != "default" else [tmpl]
# find all .cfg files in project dir
cfg2 = ConfigParser()
cfg2.read(config_path)
project_id = kwargs.get("id", None)
cfg2["project"]["id"] = project_id
config_file_path = project_dir.resolve() / "kag_config.cfg"
with open(config_file_path, "w") as config_file:
    cfg2.write(config_file)
delete_cfg = kwargs.get("delete_cfg", False)
if delete_cfg:
    os.remove(config_path)
return project_dir
@thundax-lyp
Copy link
Contributor

@AIREBA1
Copy link
Author

AIREBA1 commented Dec 5, 2024

@thundax-lyp
Copy link
Contributor

pip list 看看

@AIREBA1
Copy link
Author

AIREBA1 commented Dec 6, 2024

pip list 看看

aiohappyeyeballs 2.4.4  
aiohttp 3.11.9  
aiosignal 1.3.1  
annotated-types 0.7.0  
anyio 4.6.2.post1  
async-timeout 5.0.1  
attrs 24.2.0  
beautifulsoup4 4.12.3  
bs4 0.0.2  
bzip2 1.0.8  
ca-certificates 2024.8.30  
cachetools 5.3.2  
certifi 2023.11.17  
cffi 1.17.1  
charset-normalizer 3.3.2  
click 8.1.7  
colorama 0.4.6  
cryptography 44.0.0  
dashscope 1.20.13  
dataclasses-json 0.6.7  
dateutils 0.6.12  
deprecated 1.2.15  
distro 1.9.0  
elastic-transport 8.15.1  
elasticsearch 8.10.0  
exceptiongroup 1.2.2  
frozenlist 1.5.0  
greenlet 3.1.1  
h11 0.14.0  
httpcore 1.0.7  
httpx 0.27.2  
idna 3.10  
iniconfig 2.0.0  
jieba 0.42.1  
jinja2 3.0.3  
jiter 0.8.0  
joblib 1.4.2  
json5 0.10.0  
jsonpatch 1.33  
jsonpointer 3.0.0  
langchain-community 0.0.38  
langchain-core 0.1.53  
langchain-text-splitters 0.0.1  
langsmith 0.1.147  
libffi 3.4.2  
libsqlite 3.47.0  
libzlib 1.3.1  
lxml 5.3.0  
markdown 3.7  
markdown-it-py 3.0.0  
markupsafe 3.0.2  
marshmallow 3.23.1  
mdurl 0.1.2  
multidict 6.1.0  
mypy-extensions 1.0.0  
neo4j 5.27.0  
networkx 3.1  
nltk 3.8.1  
numpy 1.23.1  
ollama 0.3.3  
openai 1.55.3  
openspg-knext 0.5.2b2  
openssl 3.4.0  
orjson 3.10.12  
packaging 23.2  
pandas 2.2.3  
pathlib 1.0.1  
pdfminer-six 20231228  
pip 24.3.1  
pluggy 1.5.0  
propcache 0.2.1  
protobuf 3.20.1  
psutil 6.1.0  
pycparser 2.22  
pycryptodome 3.21.0  
pydantic 2.5.2  
pydantic-core 2.14.5  
pygments 2.17.2  
pypdf 5.1.0  
pytest 7.4.2  
python 3.10.15  
python-dateutil 2.8.2  
python-docx 1.1.2  
pytz 2024.2  
pyyaml 6.0.2  
regex 2024.11.6  
requests 2.31.0  
requests-toolbelt 1.0.0  
retrying 1.3.4  
rich 13.9.4  
schedule 1.2.2  
setuptools 60.2.0  
shellingham 1.5.4  
six 1.16.0  
sniffio 1.3.1  
soupsieve 2.6  
sqlalchemy 2.0.36  
tabulate 0.9.0  
tenacity 8.5.0  
tk 8.6.13  
tomli 2.2.1  
tqdm 4.66.1  
typer 0.14.0  
typing-extensions 4.12.2  
typing-inspect 0.9.0  
tzdata 2024.2  
ucrt 10.0.22621.0  
urllib3 1.26.16  
vc 14.3  
vc14_runtime 14.42.34433  
vs2015_runtime 14.42.34433  
websocket-client 1.8.0  
wget 3.2  
wheel 0.45.1  
wrapt 1.17.0  
xz 5.2.6  
yarl 1.18.3  

@caszkgui
Copy link
Collaborator

caszkgui commented Dec 6, 2024

问题报错源自于D:\xxx\kagdemo\Lib\site-packages\knext\command\sub_command\project.py 报错行来自于53行的import kag.templates.project

def _render_template(namespace: str, tmpl: str, **kwargs): config_path = kwargs.get("config_path", None) project_dir = Path(namespace) if not project_dir.exists(): project_dir.mkdir()

import kag.templates.project--------------------------------------------------------这里

src = Path(kag.templates.project.__path__[0])
copytree(
    src,
    project_dir.resolve(),
    namespace=namespace,
    root=namespace,
    tmpl=tmpl,
    **kwargs,
)

import kag.templates.schema

src = Path(kag.templates.schema.__path__[0]) / f"{{{{{tmpl}}}}}.schema.tmpl"
if not src.exists():
    click.secho(
        f"ERROR: No such schema template: {tmpl}.schema.tmpl",
        fg="bright_red",
    )
dst = project_dir.resolve() / "schema" / f"{{{{{tmpl}}}}}.schema.tmpl"
copyfile(src, dst, namespace=namespace, **{tmpl: namespace})

tmpls = [tmpl, "default"] if tmpl != "default" else [tmpl]
# find all .cfg files in project dir
cfg2 = ConfigParser()
cfg2.read(config_path)
project_id = kwargs.get("id", None)
cfg2["project"]["id"] = project_id
config_file_path = project_dir.resolve() / "kag_config.cfg"
with open(config_file_path, "w") as config_file:
    cfg2.write(config_file)
delete_cfg = kwargs.get("delete_cfg", False)
if delete_cfg:
    os.remove(config_path)
return project_dir

In developer mode, KAG should be installed through git clone https://github.com/OpenSPG/KAG.git && cd ./KAG && pip install -e .

You can refer to Quick Start to get more detail information.

@thundax-lyp
Copy link
Contributor

项目安装好后,环境中应该存在openspg-kag。

https://github.com/OpenSPG/KAG/blob/master/setup.py
LN:17

package_name = "openspg-kag"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants