No module named 'langchain_community.chat_models.vertexai'
Here's how to solve this problem. Error:
(base) (ragas_rel) PS E:\code\python-project\ragas_rel> uv run python main.py
Traceback (most recent call last):
File "E:\code\python-project\ragas_rel\main.py", line 5, in
I’ve also just started using this library and ran into the same issues as you. I’m so disappointed with it that I probably won’t use it again in the future.
Once I finish running the documentation, I’m planning to switch to something else. It seems like a project called OpenEval might be better.
Until ragas fixes this issue upstream, a possible workaround is to pin langchain-community<0.4.2.
#Hi! 👋
ChatVertexAI has been deprecated. You can switch to ChatGoogleGenerativeAI and GoogleGenerativeAI from the langchain_google_genai package instead.
I’ve opened a PR that updates these usages and adds the required dependency. Feel free to take a look, and let me know if you have any questions or run into issues 🙂 PR: #2739
Hi @liuwencan, I ran into the same issue and found the root cause.
langchain_community.chat_models.vertexai was removed in newer versions.
The fix is to use langchain_google_vertexai directly instead.
I've submitted PR #2746 that fixes this. You can try it by installing from my fork until it gets merged:
pip install git+https://github.com/GoldSharon/ragas.git
Environment where fix was verified:
- ragas: 0.4.3
- langchain-community: 0.4.2
- langchain-google-vertexai: 3.2.3
- langchain-core: 1.4.0
- langchain: 1.3.1
Hi everyone! 👋
I ran into this exact top-level crash today as well. I took a slightly different, more defensive approach in PR #2749.
Instead of switching underlying libraries or forcing a new mandatory cloud dependency onto core Ragas users who might not use Vertex AI, PR #2749 wraps the legacy imports in a try-except ImportError block and conditionally handles VERTEXAI_AVAILABLE.
This safely stops the hard crash for everyone on modern setups immediately, maintains absolute backward compatibility for legacy users, and keeps the core package lightweight. Would love to get your thoughts on this approach!
this worked for me:
uvx
--with "langchain-community<0.4"
--with "langchain-google-vertexai"
ragas quickstart rag_eval
According to Claude, the chat_models.vertexai module was removed from langchain since version 1.0 . Then a fix is to downgrade to a version where the module still exists.
The following worked for me :
pip uninstall -y langchain langchain_community langchain_openai pip install "langchain<1.0" "langchain_community<1.0" "langchain_openai<1.0" --no-cache-dir
(ragas 0.4.3 ; langchain 0.3.30 ; langchain-community 0.3.31 ; langchain-openai 0.3.35)
Looking at the activity of this project, it looks like its dead 😐
need the feedback of this issue
I ran into the same problem when I tried running the SingleTurnSample example in ragas's homepage.