[BUG] Can't import crewai -> PydanticUserError
Description
Because I have some issues with older version of CrewAI which make it unusable, I tried to install the newest Python, create new virtual environment and install the newest CrewAI version. However I can't import it because it throws exception.
Steps to Reproduce
- Create fresh virtual environment using
python -m venv - Install current CrewAI with pip
- Try to
import crewai
Expected behavior
It should import the crewai without any error.
Screenshots/Code snippets
Python file:
import crewai
Output:
Exception has occurred: PydanticUserError
The `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead in class `SecretStr`.
For further information visit https://errors.pydantic.dev/2.9/u/custom-json-schema
File "C:\Users\mikolas\projects\crew-investor\test3.py", line 4, in <module>
import crewai
pydantic.errors.PydanticUserError: The `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead in class `SecretStr`.
For further information visit https://errors.pydantic.dev/2.9/u/custom-json-schema
Operating System
Windows 10
Python Version
3.12
crewAI Version
0.65.2
crewAI Tools Version
(I didn't install the tools)
Virtual Environment
Venv
Evidence
Possible Solution
None
Additional context
None
Same problem here. Tried installing it fresh today. This happened after I installed langchain-openai. Those were the two packages installed in the environment.
pip install --upgrade crewai crewai-tools
does this help? It should fix dependencies and their versions.
After deleting my .venv folder, creating fresh one and installing crewai again, it works now. I even tried to install langchain-openai as well, no problem.
@BurgosNY Can you please try it again like this?
P.S. @BurgosNY I think you don't need to install langchain-openai manually anymore since CrewAI now uses LiteLLM for handling the communication with selected model: https://docs.crewai.com/how-to/LLM-Connections/
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
i am trying to have crewAI running on Google Colab and is facing the same issue. Few months back it was working. Any ideas how to fix it?