Cannot import langchain.agents.load_tools
Asked Answered
P

3

8

I am trying to use LangChain Agents and am unable to import load_tools. Version: langchain==0.0.27

I tried these:

from langchain.agents import initialize_agent
from langchain.llms import OpenAI
from langchain.agents import load_tools

shows output

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-36-8eb0012265d0> in <module>
      1 from langchain.agents import initialize_agent
      2 from langchain.llms import OpenAI
----> 3 from langchain.agents import load_tools

ImportError: cannot import name 'load_tools' from 'langchain.agents' (C:\ProgramData\Anaconda3\lib\site-packages\langchain\agents\__init__.py)
Paramorphism answered 24/2, 2023 at 3:22 Comment(2)
Are you sure about that version? Because they are at 0.0.93Fagot
What python version are you using?Specter
S
4

I had a similar issue installing langchain with all integrations via pip install langchain[all].

This installed some older langchain version and I could not even import the module langchain.agents.load_tools since it did not exist.

I just fixed it with a langchain upgrade to the latest version using pip install langchain --upgrade.

After that, I was able to import it with from langchain.agents import load_tools as expected.

Sottish answered 12/9, 2023 at 10:37 Comment(0)
I
3

This post is 1 month old which is basically 1 year in langchain years. Alot has changed. Try updating to the latest version

>= to this 

langchain==0.0.134


from langchain.agents import load_tools
tool_names = [...]
llm = ...
tools = load_tools(tool_names, llm=llm)
Ical answered 14/4, 2023 at 13:37 Comment(0)
S
2

I had the same problem using python 3.7.9, I downloaded python 3.10.10 instead and it worked.

Specter answered 8/3, 2023 at 23:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.