安装依赖遇到的报错
ERROR: pip's dependency resolver(依赖解析器) does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-genai 1.15.0 requires anyio<5.0.0,>=4.8.0, but you have anyio 3.7.1 which is incompatible. langchain-community 0.3.26 requires langchain<1.0.0,>=0.3.26, but you have langchain 0.0.341 which is incompatible. langchain-community 0.3.26 requires langchain-core<1.0.0,>=0.3.66, but you have langchain-core 0.0.6 which is incompatible. langchain-community 0.3.26 requires langsmith>=0.1.125, but you have langsmith 0.0.92 which is incompatible. langchain-ollama 0.3.3 requires langchain-core<1.0.0,>=0.3.60, but you have langchain-core 0.0.6 which is incompatible. langchain-text-splitters 0.3.8 requires langchain-core<1.0.0,>=0.3.51, but you have langchain-core 0.0.6 which is incompatible. langfuse 2.44.0 requires anyio<5.0.0,>=4.4.0, but you have anyio 3.7.1 which is incompatible. langfuse 2.44.0 requires packaging<24.0,>=23.2, but you have packaging 24.2 which is incompatible. open-webui 0.6.15 requires aiohttp==3.11.11, but you have aiohttp 3.12.13 which is incompatible. open-webui 0.6.15 requires chromadb==0.6.3, but you have chromadb 0.4.14 which is incompatible. open-webui 0.6.15 requires fastapi==0.115.7, but you have fastapi 0.104.1 which is incompatible. open-webui 0.6.15 requires langchain==0.3.24, but you have langchain 0.0.341 which is incompatible. open-webui 0.6.15 requires langchain-community==0.3.23, but you have langchain-community 0.3.26 which is incompatible. open-webui 0.6.15 requires pydantic==2.10.6, but you have pydantic 2.11.7 which is incompatible. open-webui 0.6.15 requires sentence-transformers==4.1.0, but you have sentence-transformers 2.2.2 which is incompatible. open-webui 0.6.15 requires sqlalchemy==2.0.38, but you have sqlalchemy 2.0.41 which is incompatible. open-webui 0.6.15 requires uvicorn[standard]==0.34.2, but you have uvicorn 0.24.0.post1 which is incompatible. pymilvus 2.5.0 requires python-dotenv<2.0.0,>=1.0.1, but you have python-dotenv 1.0.0 which is incompatible. Successfully installed anyio-3.7.1 chroma-hnswlib-0.7.3 chromadb-0.4.14 diskcache-5.6.3 fastapi-0.104.1 langchain-0.0.341 langchain-core-0.0.6 langsmith-0.0.92 llama-cpp-python-0.2.22 numpy-1.26.4 pulsar-client-3.7.0 python-dotenv-1.0.0 sentence-transformers-2.2.2 starlette-0.27.0 tenacity-8.5.0 uvicorn-0.24.0.post1
环境存在open-webui和当前的RAG项目的依赖,两者对langchain、chromadb等包的版本要求冲突。
解决方法:通过虚拟环境隔离不同项目的依赖环境。
#创建虚拟环境
python -m venv venv
#Windows 激活虚拟环境
venv\Scripts\activate
#Linux/macOs 激活虚拟环境
source venv/bin/activate
在虚拟环境安装依赖
构建向量数据库遇到的报错
(venv) E:\Ollama\rag-deepseek-ollama>python app/main.py --build
正在构建向量数据库...
Traceback (most recent call last):
File "E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\langchain\embeddings\huggingface.py", line 57, in __init__
import sentence_transformers
File "E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\sentence_transformers\__init__.py", line 3, in <module>
from .datasets import SentencesDataset, ParallelSentencesDataset
File "E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\sentence_transformers\datasets\__init__.py", line 3, in <module>
from .ParallelSentencesDataset import ParallelSentencesDataset
File "E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\sentence_transformers\datasets\ParallelSentencesDataset.py", line 4, in <module>
from .. import SentenceTransformer
File "E:\Ollama\rag-deepseek-ollama\venv\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' (E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\huggingface_hub\__init__.py)The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\Ollama\rag-deepseek-ollama\app\main.py", line 33, in <module>
main()
File "E:\Ollama\rag-deepseek-ollama\app\main.py", line 14, in main
create_vector_db()
File "E:\Ollama\rag-deepseek-ollama\app\retrieval.py", line 48, in create_vector_db
embeddings = HuggingFaceEmbeddings(
^^^^^^^^^^^^^^^^^^^^^^
File "E:\Ollama\rag-deepseek-ollama\venv\Lib\site-packages\langchain\embeddings\huggingface.py", line 60, in __init__
raise ImportError(
ImportError: Could not import sentence_transformers python package. Please install it with `pip install sentence-transformers`.
由于目标 计算机积极拒绝,无法连接
这个是在部署模型和跑模型时候总是遇到的问题,很多次是忘记启动Ollama了,重新启动就OK了;很多网络配置问题都是通过代理(clash verge)解决了。