Getting Started code doesn't work
I just installed crewai using pip and ran the code in the Getting started section. It throws the following error.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[4], line 2
1 import os
----> 2 from crewai import Agent, Task, Crew, Process
4 os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
6 # You can choose to use a local model through Ollama for example. See ./docs/how-to/llm-connections.md for more information.
7 # from langchain_community.llms import Ollama
8 # ollama_llm = Ollama(model="openhermes")
9
10 # Install duckduckgo-search for this example:
11 # !pip install -U duckduckgo-search
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/__init__.py:1
----> 1 from crewai.agent import Agent
2 from crewai.crew import Crew
3 from crewai.process import Process
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agent.py:22
10 from pydantic import (
11 UUID4,
12 BaseModel,
(...)
18 model_validator,
19 )
20 from pydantic_core import PydanticCustomError
---> 22 from crewai.agents import (
23 CacheHandler,
24 CrewAgentExecutor,
25 CrewAgentOutputParser,
26 ToolsHandler,
27 )
28 from crewai.utilities import I18N, Logger, Prompts, RPMController
31 class Agent(BaseModel):
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agents/__init__.py:2
1 from .cache.cache_handler import CacheHandler
----> 2 from .executor import CrewAgentExecutor
3 from .output_parser import CrewAgentOutputParser
4 from .tools_handler import ToolsHandler
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agents/executor.py:16
14 from crewai.agents.cache.cache_hit import CacheHit
15 from crewai.tools.cache_tools import CacheTools
---> 16 from crewai.utilities import I18N
19 class CrewAgentExecutor(AgentExecutor):
20 i18n: I18N = I18N()
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/__init__.py:4
2 from .logger import Logger
3 from .prompts import Prompts
----> 4 from .rpm_controller import RPMController
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py:10
5 from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, model_validator
7 from crewai.utilities.logger import Logger
---> 10 class RPMController(BaseModel):
11 model_config = ConfigDict(arbitrary_types_allowed=True)
12 max_rpm: Union[int, None] = Field(default=None)
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py:15, in RPMController()
13 logger: Logger = Field(default=None)
14 _current_rpm: int = PrivateAttr(default=0)
---> 15 _timer: threading.Timer | None = PrivateAttr(default=None)
16 _lock: threading.Lock = PrivateAttr(default=None)
18 @model_validator(mode="after")
19 def reset_counter(self):
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
I'm currently using python 3.9
Hey there, the issue is the python version :) python version needs to be at least 3.10.0
-- João Moura @joaomdmoura http://twitter.com/joaomdmoura
Em qui., 22 de fev. de 2024 às 02:47, CohleM @.***> escreveu:
I just installed crewai using pip and ran the code in the Getting started section. The throws the following error.
TypeError Traceback (most recent call last) Cell In[4], line 2 1 import os ----> 2 from crewai import Agent, Task, Crew, Process 4 os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY" 6 # You can choose to use a local model through Ollama for example. See ./docs/how-to/llm-connections.md for more information. 7 # from langchain_community.llms import Ollama 8 # ollama_llm = Ollama(model="openhermes") 9 10 # Install duckduckgo-search for this example: 11 # !pip install -U duckduckgo-search
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/init.py:1 ----> 1 from crewai.agent import Agent 2 from crewai.crew import Crew 3 from crewai.process import Process
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agent.py:22 10 from pydantic import ( 11 UUID4, 12 BaseModel, (...) 18 model_validator, 19 ) 20 from pydantic_core import PydanticCustomError ---> 22 from crewai.agents import ( 23 CacheHandler, 24 CrewAgentExecutor, 25 CrewAgentOutputParser, 26 ToolsHandler, 27 ) 28 from crewai.utilities import I18N, Logger, Prompts, RPMController 31 class Agent(BaseModel):
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agents/init.py:2 1 from .cache.cache_handler import CacheHandler ----> 2 from .executor import CrewAgentExecutor 3 from .output_parser import CrewAgentOutputParser 4 from .tools_handler import ToolsHandler
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/agents/executor.py:16 14 from crewai.agents.cache.cache_hit import CacheHit 15 from crewai.tools.cache_tools import CacheTools ---> 16 from crewai.utilities import I18N 19 class CrewAgentExecutor(AgentExecutor): 20 i18n: I18N = I18N()
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/init.py:4 2 from .logger import Logger 3 from .prompts import Prompts ----> 4 from .rpm_controller import RPMController
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py:10 5 from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, model_validator 7 from crewai.utilities.logger import Logger ---> 10 class RPMController(BaseModel): 11 model_config = ConfigDict(arbitrary_types_allowed=True) 12 max_rpm: Union[int, None] = Field(default=None)
File ~/anaconda3/envs/crewai/lib/python3.9/site-packages/crewai/utilities/rpm_controller.py:15, in RPMController() 13 logger: Logger = Field(default=None) 14 _current_rpm: int = PrivateAttr(default=0) ---> 15 _timer: threading.Timer | None = PrivateAttr(default=None) 16 _lock: threading.Lock = PrivateAttr(default=None) 18 @model_validator(mode="after") 19 def reset_counter(self):
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
I'm currently using python 3.9
— Reply to this email directly, view it on GitHub https://github.com/joaomdmoura/crewAI/issues/264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3NZQVV5XD4HQ6CMPXI3YU4O2NAVCNFSM6AAAAABDUWMB6KVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2DQNZWHAZDOMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thanks @joaomdmoura but crewai assistant recommends 3.8 or above
same issue. Suggest update CrewAI doc. @joaomdmoura