lexiforest / curl_cffi

Python binding for curl-impersonate fork via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.
https://curl-cffi.readthedocs.io/
MIT License
2.52k stars 266 forks source link

[BUG]python 3.10.8使用DuckDuckGoSearchRun模块报异常 #291

Closed fish2018 closed 7 months ago

fish2018 commented 7 months ago

python 3.10.8使用DuckDuckGoSearchRun模块

from langchain_community.tools import DuckDuckGoSearchRun
web_search = DuckDuckGoSearchRun()

Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/langchain_community/utilities/duckduckgo_search.py", line 33, in validate_environment
    from duckduckgo_search import DDGS  # noqa: F401
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/duckduckgo_search/__init__.py", line 10, in <module>
    from .duckduckgo_search import DDGS
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search.py", line 7, in <module>
    from .duckduckgo_search_async import AsyncDDGS
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 13, in <module>
    from curl_cffi import requests
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/curl_cffi/__init__.py", line 18, in <module>
    from ._wrapper import ffi, lib  # type: ignore
ImportError: dlopen(/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/curl_cffi/_wrapper.abi3.so, 2): Library not loaded: @loader_path/.dylibs/libcurl-impersonate-chrome.4.dylib
  Referenced from: /Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/curl_cffi/_wrapper.abi3.so
  Reason: no suitable image found.  Did find:
    /Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/curl_cffi/.dylibs/libcurl-impersonate-chrome.4.dylib: cannot load 'libcurl-impersonate-chrome.4.dylib' (load command 0x80000034 is unknown)
    /Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/curl_cffi/.dylibs/libcurl-impersonate-chrome.4.dylib: cannot load 'libcurl-impersonate-chrome.4.dylib' (load command 0x80000034 is unknown)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/chatdesk/enhance.py", line 86, in <module>
    web_search = DuckDuckGoSearchRun()
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/langchain_core/load/serializable.py", line 120, in __init__
    super().__init__(**kwargs)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1066, in pydantic.main.validate_model
  File "pydantic/fields.py", line 439, in pydantic.fields.ModelField.get_default
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1102, in pydantic.main.validate_model
  File "/Users/macbookpro/Desktop/chatdesk/env/lib/python3.10/site-packages/langchain_community/utilities/duckduckgo_search.py", line 35, in validate_environment
    raise ImportError(
ImportError: Could not import duckduckgo-search python package. Please install it with `pip install -U duckduckgo-search`.
perklet commented 7 months ago

Older versions of macOS are not supported, please use a recent one. See https://github.com/yifeikong/curl-impersonate/pull/53 for updates on the fix.

升级下 macOS 版本吧,老版本不支持。

deedy5 commented 7 months ago

ImportError: Could not import duckduckgo-search python package. Please install it with pip install -U duckduckgo-search.

Install pip install -U duckduckgo_search