依赖问题,github Asana 无法导入句子_transformers python 包。请使用`pip install Sentence-transformers`安装它

问题描述 投票:0回答:1

刚刚开始学习LangChain,并将我的项目搬到LangChain上。 为了继续前进,我得到了这个 github 项目: https://github.com/Cbase-ai/asana-task-agent 我确实安装了一切。内容包含:

  • python 3.9.13
  • x64 Windows 英特尔
  • 当然是环境。

我试图解决许多配置的问题,但我总是遇到一些库问题。

这就是:

aiohappyeyeballs                         2.4.3
aiohttp                                  3.10.10
aiosignal                                1.3.1
altair                                   5.4.1
annotated-types                          0.7.0
anthropic                                0.38.0
anyio                                    4.6.2.post1
argilla                                  2.4.0
asana                                    5.0.7
asgiref                                  3.8.1
async-timeout                            4.0.3
attrs                                    24.2.0
backoff                                  2.2.1
bcrypt                                   4.2.0
blinker                                  1.8.2
build                                    1.2.2.post1
cachetools                               5.5.0
certifi                                  2024.8.30
cffi                                     1.17.1
charset-normalizer                       3.4.0
chroma-hnswlib                           0.7.6
chromadb                                 0.5.17
click                                    8.1.7
colorama                                 0.4.6
coloredlogs                              15.0.1
cryptography                             43.0.3
dataclasses-json                         0.6.7
datasets                                 3.1.0
defusedxml                               0.7.1
Deprecated                               1.2.14
dill                                     0.3.8
distro                                   1.9.0
durationpy                               0.9
exceptiongroup                           1.2.2
fastapi                                  0.115.4
filelock                                 3.16.1
flatbuffers                              24.3.25
frozenlist                               1.5.0
fsspec                                   2024.9.0
gitdb                                    4.0.11
GitPython                                3.1.43
google-auth                              2.35.0
googleapis-common-protos                 1.65.0
greenlet                                 3.1.1
grpcio                                   1.67.1
grpcio-status                            1.48.2
h11                                      0.14.0
httpcore                                 1.0.6
httptools                                0.6.4
httpx                                    0.27.2
huggingface-hub                          0.26.2
humanfriendly                            10.0
idna                                     3.10
importlib_metadata                       8.4.0
importlib_resources                      6.4.5
Jinja2                                   3.1.4
jiter                                    0.7.0
joblib                                   1.4.2
jsonpatch                                1.33
jsonpointer                              3.0.0
jsonschema                               4.23.0
jsonschema-specifications                2024.10.1
kubernetes                               31.0.0
langchain                                0.2.6
langchain-anthropic                      0.1.16
langchain-chroma                         0.1.2
langchain-community                      0.2.6
langchain-core                           0.2.43
langchain-openai                         0.1.10
langchain-text-splitters                 0.2.4
langsmith                                0.1.139
lxml                                     5.3.0
markdown-it-py                           3.0.0
MarkupSafe                               3.0.2
marshmallow                              3.23.1
mdurl                                    0.1.2
mmh3                                     5.0.1
monotonic                                1.6
mpmath                                   1.3.0
multidict                                6.1.0
multiprocess                             0.70.16
mypy-extensions                          1.0.0
narwhals                                 1.13.1
networkx                                 3.2.1
nltk                                     3.9.1
numpy                                    1.26.4
oauthlib                                 3.2.2
onnxruntime                              1.19.2
openai                                   1.53.0
opentelemetry-api                        1.27.0
opentelemetry-exporter-otlp-proto-common 1.27.0
opentelemetry-exporter-otlp-proto-grpc   1.27.0
opentelemetry-instrumentation            0.48b0
opentelemetry-instrumentation-asgi       0.48b0
opentelemetry-instrumentation-fastapi    0.48b0
opentelemetry-proto                      1.27.0
opentelemetry-sdk                        1.27.0
opentelemetry-semantic-conventions       0.48b0
opentelemetry-util-http                  0.48b0
orjson                                   3.10.11
overrides                                7.7.0
packaging                                24.1
pandas                                   2.2.3
pdfminer.six                             20221105
pdfplumber                               0.9.0
pillow                                   10.4.0
pip                                      22.0.4
posthog                                  3.7.0
propcache                                0.2.0
protobuf                                 4.25.5
pyarrow                                  18.0.0
pyasn1                                   0.6.1
pyasn1_modules                           0.4.1
pycparser                                2.22
pydantic                                 2.9.2
pydantic_core                            2.23.4
pydeck                                   0.9.1
Pygments                                 2.18.0
PyPika                                   0.48.9
pyproject_hooks                          1.2.0
pyreadline3                              3.5.4
python-dateutil                          2.9.0.post0
python-dotenv                            0.13.0
pytz                                     2024.2
PyYAML                                   6.0.2
referencing                              0.35.1
regex                                    2024.9.11
requests                                 2.32.3
requests-oauthlib                        2.0.0
requests-toolbelt                        1.0.0
rich                                     13.9.4
rpds-py                                  0.20.1
rsa                                      4.9
safetensors                              0.4.5
scikit-learn                             1.5.2
scipy                                    1.13.1
sentence-transformers                    2.2.2
sentencepiece                            0.2.0
setuptools                               58.1.0
shellingham                              1.5.4
six                                      1.16.0
smmap                                    5.0.1
sniffio                                  1.3.1
SQLAlchemy                               2.0.36
starlette                                0.41.2
streamlit                                1.36.0
sympy                                    1.13.1
tenacity                                 8.5.0
threadpoolctl                            3.5.0
tiktoken                                 0.8.0
tokenizers                               0.20.1
toml                                     0.10.2
tomli                                    2.0.2
torch                                    2.5.1
torchvision                              0.20.1
tornado                                  6.4.1
tqdm                                     4.66.6
transformers                             4.46.1
typer                                    0.12.5
typing_extensions                        4.12.2
typing-inspect                           0.9.0
tzdata                                   2024.2
unstructured                             0.3.0
urllib3                                  2.2.3
uvicorn                                  0.32.0
Wand                                     0.6.13
watchdog                                 4.0.2
watchfiles                               0.24.0
websocket-client                         1.8.0
websockets                               13.1
wrapt                                    1.16.0
xxhash                                   3.5.0
yarl                                     1.17.1
zipp                                     3.20.2
streamlit run rag-task-agent.py

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://192.168.1.221:8501

C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\rag-task-agent.py:47: LangChainDeprecationWarning: The class `HuggingFaceEmbeddings` was deprecated in LangChain 0.2.2 and will be removed in 0.3.0. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run `pip install -U langchain-huggingface` and import as `from langchain_huggingface import HuggingFaceEmbeddings`.
  embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
2024-11-04 11:59:25.950 Uncaught app exception
Traceback (most recent call last):
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_community\embeddings\huggingface.py", line 71, in __init__
    import sentence_transformers
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\__init__.py", line 3, in <module>
    from .datasets import SentencesDataset, ParallelSentencesDataset
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\datasets\__init__.py", line 3, in <module>    
    from .ParallelSentencesDataset import ParallelSentencesDataset
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\datasets\ParallelSentencesDataset.py", line 4, in <module>
    from .. import SentenceTransformer
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\SentenceTransformer.py", line 12, in <module> 
    from huggingface_hub import HfApi, HfFolder, Repository, hf_hub_url, cached_download
ImportError: cannot import name 'cached_download' from 'huggingface_hub' (C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\huggingface_hub\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 589, in _run_script
    exec(code, module.__dict__)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\rag-task-agent.py", line 52, in <module>
    db = get_chroma_instance()
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 168, in wrapper     
    return cached_func(*args, **kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 197, in __call__    
    return self._get_or_create_cached_value(args, kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 224, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 280, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\rag-task-agent.py", line 47, in get_chroma_instance
    embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_core\_api\deprecation.py", line 215, in warn_if_direct_instance
    return wrapped(self, *args, **kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_community\embeddings\huggingface.py", line 74, in __init__
    raise ImportError(
ImportError: Could not import sentence_transformers python package. Please install it with `pip install sentence-transformers`.
2024-11-04 11:59:26.496 Examining the path of torch.classes raised: Tried to instantiate class '__path__._path', but it does not exist! Ensure that it is registered via torch::class_
2024-11-04 11:59:38.355 Uncaught app exception
Traceback (most recent call last):
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_community\embeddings\huggingface.py", line 71, in __init__
    import sentence_transformers
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\__init__.py", line 3, in <module>
    from .datasets import SentencesDataset, ParallelSentencesDataset
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\datasets\__init__.py", line 3, in <module>    
    from .ParallelSentencesDataset import ParallelSentencesDataset
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\datasets\ParallelSentencesDataset.py", line 4, in <module>
    from .. import SentenceTransformer
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\sentence_transformers\SentenceTransformer.py", line 12, in <module> 
    from huggingface_hub import HfApi, HfFolder, Repository, hf_hub_url, cached_download
ImportError: cannot import name 'cached_download' from 'huggingface_hub' (C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\huggingface_hub\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 589, in _run_script
    exec(code, module.__dict__)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\rag-task-agent.py", line 52, in <module>
    db = get_chroma_instance()
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 168, in wrapper     
    return cached_func(*args, **kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 197, in __call__    
    return self._get_or_create_cached_value(args, kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 224, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 280, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\rag-task-agent.py", line 47, in get_chroma_instance
    embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_core\_api\deprecation.py", line 215, in warn_if_direct_instance
    return wrapped(self, *args, **kwargs)
  File "C:\Users\alute\Desktop\ASANAGPT\ASANAGPT4\asana-task-agent\env39\lib\site-packages\langchain_community\embeddings\huggingface.py", line 74, in __init__
    raise ImportError(
ImportError: Could not import sentence_transformers python package. Please install it with `pip install sentence-transformers`.
2024-11-04 11:59:38.805 Examining the path of torch.classes raised: Tried to instantiate class '__path__._path', but it does not exist! Ensure that it is registered via torch::class_

请向我解释一下,我尝试了一切可能的方法,但似乎我错过了一些东西。 也许需求文件来自某个旧项目?很难说

我尝试了很多与库的组合,但不是每一个都确定。

运行代码并了解发生了什么

python langchain agent py-langchain asana-api
1个回答
0
投票

你可以尝试一下吗

pip install -U langchain-huggingface

您可能还需要

...并导入为

from langchain_huggingface import HuggingFaceEmbeddings

我对此不太确定,只是看看你的日志。谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.