crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] Can't import crewai -> PydanticUserError

Open Michal-Mikolas opened this issue 1 year ago • 4 comments

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

  1. Create fresh virtual environment using python -m venv
  2. Install current CrewAI with pip
  3. 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

Code_FPjepx1VoF

Possible Solution

None

Additional context

None

Michal-Mikolas avatar Sep 29 '24 21:09 Michal-Mikolas

Same problem here. Tried installing it fresh today. This happened after I installed langchain-openai. Those were the two packages installed in the environment.

BurgosNY avatar Sep 29 '24 22:09 BurgosNY

pip install --upgrade crewai crewai-tools does this help? It should fix dependencies and their versions.

voytas75 avatar Sep 30 '24 09:09 voytas75

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?

Michal-Mikolas avatar Oct 01 '24 07:10 Michal-Mikolas

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/

Michal-Mikolas avatar Oct 01 '24 08:10 Michal-Mikolas

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.

github-actions[bot] avatar Oct 31 '24 12:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Nov 05 '24 12:11 github-actions[bot]

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?

darrenchiu avatar Nov 20 '24 08:11 darrenchiu