0

Just intalled Lanchain. Been going through the first few steps of the getting started tutorial without a problem till I reach the Agents section.

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI
Traceback (most recent call last):
  File "/langchain/agents.py", line 4, in <module>
    from langchain.agents import load_tools
ModuleNotFoundError: No module named 'langchain.agents'

I am running lanchain in a virtual environment in python 3.9. Installed langchain with the pip install command as shown in the docs.

Not sure why this module specifically could be missing

nid
  • 155
  • 3
  • 9
  • 1
    Could you run `pip show langchain` in your terminal? Please verify that you are using the correct `venv` also with `which pip` and `which python`. – DWe1 Apr 15 '23 at 09:51

2 Answers2

0

Switched to python 3.9 version 0.0.135 which seems to have fixed the issue.

https://pypi.org/project/langchain/0.0.135/

nid
  • 155
  • 3
  • 9
0

I came across this error and fixed it by changing the import to the following:

from langchain.agents.agent_types import AgentType

This is where AgentType is imported from in the langchain/agents/init.py file.