I’m trying to run a LangChain script that uses several modules including langchain
, langchain-core
, langchain-openai
, and langchain-groq
. However, I keep encountering the following error:
Traceback (most recent call last):
File "/path/to/my/directory/langchain_processor.py", line 1, in <module>
from langchain.output_parsers import (
ModuleNotFoundError: No module named 'langchain'
Unfortunately, I’m unable to import any of the modules mentioned above, including:
langchain.output_parsers
langchain_core.prompts
langchain_core.pydantic_v1
langchain_openai
langchain_groq
None of these modules can be imported, and I’m stuck with the ModuleNotFoundError
.What’s even more puzzling is that I’ve verified that all of these modules are indeed in sys.path, which means Python should be able to find them. Despite this, I’m still getting the ModuleNotFoundError.
Here is a snippet of my langchain_processor.py
script:
import os
from langchain.output_parsers import (
OutputFixingParser,
PydanticOutputParser,
)
from langchain_core.prompts import (
PromptTemplate,
)
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_openai import ChatOpenAI
from langchain_groq import ChatGroq
import json
from typing import List, Tuple
My environment.yml
file looks like this:
name: langchain-env
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- pip
- pip:
- langchain-core
- langchain-openai
- langchain-groq
- pydantic
- langchain
After activating my Conda environment, I confirmed that the packages are installed:
(langchain-env) > pip list
Package Version
------------------------ ---------
aiohttp 3.9.5
aiosignal 1.3.1
annotated-types 0.6.0
anyio 4.3.0
async-timeout 4.0.3
attrs 23.2.0
certifi 2024.2.2
charset-normalizer 3.3.2
colorama 0.4.6
dataclasses-json 0.6.6
distro 1.9.0
exceptiongroup 1.2.1
frozenlist 1.4.1
greenlet 3.0.3
groq 0.6.0
h11 0.14.0
httpcore 1.0.5
httpx 0.27.0
idna 3.7
jsonpatch 1.33
jsonpointer 2.4
langchain 0.2.0
langchain-core 0.2.0
langchain-groq 0.1.4
langchain-openai 0.1.7
langchain-text-splitters 0.2.0
langsmith 0.1.59
marshmallow 3.21.2
multidict 6.0.5
mypy-extensions 1.0.0
numpy 1.26.4
openai 1.30.1
orjson 3.10.3
packaging 23.2
pip 24.0
pydantic 2.7.1
pydantic_core 2.18.2
PyYAML 6.0.1
regex 2024.5.15
requests 2.31.0
setuptools 69.5.1
sniffio 1.3.1
SQLAlchemy 2.0.30
tenacity 8.3.0
tiktoken 0.7.0
tqdm 4.66.4
typing_extensions 4.11.0
typing-inspect 0.9.0
urllib3 2.2.1
wheel 0.43.0
yarl 1.9.4
I can’t seem to resolve this ModuleNotFoundError
. How can I properly load these modules?