You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chroma DB持久化与HTTP客户端模式均无法正常使用求助

解决方案

问题1:PersistentClient无法使用(HTTP-only模式报错)

你安装的是Chroma的HTTP客户端专用包(chromadb-client),该版本仅支持连接远程Chroma服务,无法使用本地PersistentClient。解决步骤:

  1. 卸载现有客户端包:
    pip uninstall chromadb-client -y
    
  2. 安装完整的Chroma包:
    pip install chromadb
    
  3. 修正代码参数写法(path无需关键字赋值)后重新运行:
    import chromadb
    client = chromadb.PersistentClient(path="/path/to/save/to")
    

问题2:HTTP客户端创建集合报错(连接中断)

你的HttpClient初始化成功,但本地Chroma服务端未启动,导致后续请求无响应。解决步骤:

  1. 启动Chroma服务端(需已安装完整chromadb包):
    chroma run --host localhost --port 8000
    
  2. 保持服务端运行,简化客户端代码(HttpClient默认适配FastAPI实现,无需额外指定):
    from chromadb import HttpClient
    from chromadb.config import Settings
    
    settings = Settings(allow_reset=True, anonymized_telemetry=False)
    client = HttpClient(host='localhost', port=8000, settings=settings)
    # 正常创建集合
    collection = client.create_collection(name="my_collection")
    

额外注意事项

  • 若需同时使用本地存储和HTTP客户端,必须安装完整chromadb包,而非chromadb-client
  • 确保服务端启动端口与客户端配置端口一致,避免防火墙或代理拦截请求

内容的提问来源于stack exchange,提问作者Luca Melli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 08:22:37