-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError: No module named 'langchain_community' #21880
Comments
Facing same issue |
You can try this command to install langchain_community manually. Reason: langchain-community is not automatically installed in langchain v0.2. |
Tried that too. Still getting error: ModuleNotFoundError Traceback (most recent call last) File ~/opt/anaconda3/lib/python3.9/site-packages/langchain/chat_models/init.py:27, in getattr(name) ModuleNotFoundError: No module named 'langchain_community' |
@kavyabhargava try this command to install. |
facing the same issue even after doing this |
It is usful |
Lifesaver |
you can try |
Checked other resources
Example Code
#----part0导入所需要的类
import os
import requests
from PIL import Image
from transformers import BlipProcessor, BlipForConditionalGeneration
from langchain.tools import BaseTool
from langchain import OpenAI
from langchain.agents import initialize_agent,AgentType
#----part1 初始化图像字母生成
hf_model = "Salesforce/blip-image-caption-large"
processor = BlipProcessor.from_pretrained(hf_model)
model = BlipForConditionalGeneration.from_pretrained(hf_model)
#--定义图像字母生成工具类
class ImageCapTool(BaseTool):
name = "Image captioner"
description = "为图片创作说明文案"
os.environ["OPENAI_API_KEY"] = ""
llm = OpenAI(temperature=0.2)
tools = [ImageCapTool]
agent = initialize_agent(
agent = AgentType.ZERO_SHOT_REACT_DESCRIPTION,
tools=tools,
llm=llm,
verbose = True,
)
image_url = "https://image.baidu.com/search/detail?ct=503316480&z=undefined&tn=baiduimagedetail&ipn=d&word=%E7%8E%AB%E7%91%B0&step_word=&lid=8350970360390223282&ie=utf-8&in=&cl=2&lm=-1&st=undefined&hd=undefined&latest=undefined©right=undefined&cs=1485018591,1347421720&os=1568910280,55160396&simid=3419305429,75243099&pn=6&rn=1&di=7355526631391232001&ln=1941&fr=&fmq=1716115722875_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&is=0,0&istype=0&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2Fs2.best-wallpaper.net%2Fwallpaper%2Fiphone%2F1911%2FOne-red-rose-petals-black-background_iphone_640x1136.jpg&rpstart=0&rpnum=0&adpicid=0&nojc=undefined&dyTabStr=MCwxLDMsMiw2LDQsNSw4LDcsOQ%3D%3D"
agent.invoke(input=f'{image_url}\n请创作合适的中文推广文案')
Error Message and Stack Trace (if applicable)
D:\miniconda\envs\llm\python.exe D:\langchain_code\langchain0519\demo02.py
Traceback (most recent call last):
File "D:\langchain_code\langchain0519\demo02.py", line 7, in
from langchain import OpenAI
File "D:\miniconda\envs\llm\Lib\site-packages\langchain_init_.py", line 189, in getattr
from langchain_community.llms import OpenAI
ModuleNotFoundError: No module named 'langchain_community'
Description
D:\miniconda\envs\llm\python.exe D:\langchain_code\langchain0519\demo02.py
Traceback (most recent call last):
File "D:\langchain_code\langchain0519\demo02.py", line 7, in
from langchain import OpenAI
File "D:\miniconda\envs\llm\Lib\site-packages\langchain_init_.py", line 189, in getattr
from langchain_community.llms import OpenAI
ModuleNotFoundError: No module named 'langchain_community'
System Info
D:\miniconda\envs\llm\python.exe D:\langchain_code\langchain0519\demo02.py
Traceback (most recent call last):
File "D:\langchain_code\langchain0519\demo02.py", line 7, in
from langchain import OpenAI
File "D:\miniconda\envs\llm\Lib\site-packages\langchain_init_.py", line 189, in getattr
from langchain_community.llms import OpenAI
ModuleNotFoundError: No module named 'langchain_community'
The text was updated successfully, but these errors were encountered: