crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
20.79k stars 2.87k forks source link

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' in rpm_controller.py #215

Closed nimar closed 9 months ago

nimar commented 9 months ago

I'm trying to test the examples of crewai, but the initial import of crewai fails.

I'm using crewai-0.5.0 langchain-0.1.0 langchain-openai-0.0.2.post1 on Python 3.9 on MacOS in a virtual environment.

Here's the code sample

import os
import dotenv
dotenv.load_dotenv() # defines environment variable OPENAI_API_KEY.

import crewai

This is the full stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test/.venv/lib/python3.9/site-packages/crewai/__init__.py", line 1, in <module>
    from crewai.agent import Agent
  File "test/.venv/lib/python3.9/site-packages/crewai/agent.py", line 22, in <module>
    from crewai.agents import (
  File "test/.venv/lib/python3.9/site-packages/crewai/agents/__init__.py", line 2, in <module>
    from .executor import CrewAgentExecutor
  File "test/.venv/lib/python3.9/site-packages/crewai/agents/executor.py", line 16, in <module>
    from crewai.utilities import I18N
  File "test/.venv/lib/python3.9/site-packages/crewai/utilities/__init__.py", line 4, in <module>
    from .rpm_controller import RPMController
  File "test/.venv/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py", line 10, in <module>
    class RPMController(BaseModel):
  File "test/.venv/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py", line 15, in RPMController
    _timer: threading.Timer | None = PrivateAttr(default=None)
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
joaomdmoura commented 9 months ago

The issue is with the python version, | was added in python 3.10, so not available in python 3.9 :)

lugq1990 commented 5 months ago

The issue is with the python version, | was added in python 3.10, so not available in python 3.9 :)

get the same error here, so why not to use union type to fix this?