运行Python代码提示找不到langchain_community库,环境正常仍报错求助
问题:ModuleNotFoundError: No module named 'langchain_community'
- 环境配置:Python 3.12.2,WSL2下的Ubuntu-22.04系统,使用PyCharm开发并已关联该WSL环境,虚拟环境处于激活状态
- 当前进度:跟随LangChain入门教程学习到Retrieval Chain章节,使用ollama本地运行代码
- 运行报错:执行
main.py时出现如下错误:
Traceback (most recent call last):
File "/home/myUser/repos/python/myFirstProject/main.py", line 1, in
from langchain_community.llms import Ollama
ModuleNotFoundError: No module named 'langchain_community'
- 已完成的排查操作:
- 执行
pip list确认已安装langchain-community(版本0.0.29)及相关LangChain系列包,列表如下:包名称 版本 其他包... x.x.x langchain 0.1.13 langchain-cli 0.0.21 langchain-community 0.0.29 langchain-core 0.1.34 langchain-text-splitters 0.0.1 langserve 0.0.51 langsmith 0.1.33 其他包... x.x.x - 确认所有相关包都存放在虚拟环境的
.venv/include/lib/python3.12/site-packages目录中 - 检查PyCharm的
file -> settings -> Project:myProjectName -> Python Interpreter配置,解释器版本正确,已安装包列表完整 - 尝试重装所有相关包,但问题未解决
- 执行
内容的提问来源于stack exchange,提问作者NaguiHW
相关产品推荐
相关产品推荐

