Open KaiQiang-Liu1994 opened 2 months ago
Facing same issue
You can try this command to install langchain_community manually.
pip install langchain-community
.
Reason: langchain-community is not automatically installed in langchain v0.2.
Tried that too. Still getting error: ModuleNotFoundError Traceback (most recent call last) Cell In[4], line 1 ----> 1 from langchain.chat_models import ChatOpenAI
File ~/opt/anaconda3/lib/python3.9/site-packages/langchain/chat_models/init.py:27, in getattr(name) 26 def getattr(name: str) -> None: ---> 27 from langchain_community import chat_models 29 # If not in interactive env, raise warning. 30 if not is_interactive_env():
ModuleNotFoundError: No module named 'langchain_community'
@kavyabhargava try this command to install.
pip install langchain-community --trusted-host mirrors.cloud.tencent.com
@kavyabhargava try this command to install.
pip install langchain-community --trusted-host mirrors.cloud.tencent.com
facing the same issue even after doing this
You can try this command to install langchain_community manually.
pip install langchain-community
.Reason: langchain-community is not automatically installed in langchain v0.2.
It is usful
If you are using conda, you need to add conda-forge as channel into conda.
Then you can install langchain-community package and it should start to work.
You can try this command to install langchain_community manually.
pip install langchain-community
.Reason: langchain-community is not automatically installed in langchain v0.2.
Lifesaver
you can try pip install langchain-community and if you are using openai key than pip install langchain_openai and instead of from langchain import OpenAI use from langchain_openai import OpenAI
Facing same issue
from langchain_community.llms.ollama import Ollama (try this command it will work)
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'