From 1de953b58f38c7aac3bfa593885981a0d8fa02a8 Mon Sep 17 00:00:00 2001 From: alex_q <914269@qq.com> Date: Wed, 9 Sep 2026 16:06:05 +0800 Subject: [PATCH] =?UTF-8?q?sqlite3=E5=85=BC=E5=AE=B9=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=85=8Dpython=E4=B8=8D=E5=B8=A6sqlite3?= =?UTF-8?q?=E6=88=96=E7=89=88=E6=9C=AC=E8=BF=87=E4=BD=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 6 ++++++ requirements.txt | 3 +++ 2 files changed, 9 insertions(+) diff --git a/app/main.py b/app/main.py index 92d3a3e..6a18a93 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,9 @@ +# ChromaDB 依赖 sqlite3 >= 3.35.0,部分 Linux 发行版自带版本过低 +# 使用 pysqlite3-binary 提供的现代 SQLite 替代系统 sqlite3 +__import__('pysqlite3') +import sys +sys.modules['sqlite3'] = sys.modules.pop('pysqlite3') + from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware import logging diff --git a/requirements.txt b/requirements.txt index 9aabb07..1950b9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,9 @@ uvicorn[standard]==0.52.4 pydantic==2.13.5 pydantic-settings==2.15.0 +# SQLite3 兼容层 (系统自带 sqlite3 版本过低时 ChromaDB 需要 >= 3.35.0) +pysqlite3-binary==0.5.4 + # 向量数据库 - ChromaDB 1.5+ chromadb==1.5.9