UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x97 in position 1496: invalid start byte crewai 1.15.1 error:-An error occurred while running the flow: Command ‘[‘uv’, ‘run’, ‘kickoff’]’ returned non-zero exit status 1 : RESOLVED

Hi eveyone

I am using :-
i)crewai 1.15.1
ii)ollama3.2 (local LLM)
iii)windows 11

before using the crewai run command , i execute the command:-

ollama pull llama3.2

to start the ollama ai and also confirmed it by opening the url:http://localhost:11434 in a web browser.

to intrigrate ollama3.2 in my crewai project i have included the following lines of code in my :-

…project_folder\src\project_folder_name\crews\content_crew\content_crew.py

local_llm = LLM(

#model=“ollama/llama3:70b”,

model=“ollama/llama3.2”,

base_url=“http://localhost:11434”,

timeout=300

)

and for each agent included the local_llm in the method call Agent() as follow@agent:-

@agent

def planner(self) -> Agent:

    return Agent(

        config=self.agents_config\["planner"\], **llm = local_llm** # type: ignore\[index\]

    )

while trying to run my project following error occurs:-

C:\crewai_project\blog_writer>crewai run
╭───────────────────────────────────────────────── :ocean: Flow Execution ──────────────────────────────────────────────────╮
│ │
│ Starting Flow Execution │
│ Name: ContentFlow │
│ ID: 962b4004-1d76-485d-b8f9-c9da06523aee │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────── :ocean: Flow Started ───────────────────────────────────────────────────╮
│ │
│ Flow Started │
│ Name: ContentFlow │
│ ID: 962b4004-1d76-485d-b8f9-c9da06523aee │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────── :counterclockwise_arrows_button: Flow Method Running ───────────────────────────────────────────────╮
│ │
│ Method: plan_content │
│ Status: Running │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Planning content

Topic: AI Agents
╭────────────────────────────────────────────── :white_check_mark: Flow Method Completed ──────────────────────────────────────────────╮
│ │
│ Method: plan_content │
│ Status: Completed │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Generating content on: AI Agents

╭─────────────────────────────────────────────── :counterclockwise_arrows_button: Flow Method Running ───────────────────────────────────────────────╮
│ │
│ Method: generate_content │
│ Status: Running │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Error executing listener generate_content: ‘utf-8’ codec can’t decode byte 0x97 in position 1496: invalid start byte
╭─────────────────────────────────────────────── :cross_mark: Flow Method Failed ────────────────────────────────────────────────╮
│ │
│ Method: generate_content │
│ Status: Failed │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Traceback (most recent call last):
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init_.py”, line 1925, in kickoff
asyncio.get_running_loop()
RuntimeError: no running event loop

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 198, in run_module_as_main
File “”, line 88, in run_code
File "C:\crewai_project\blog_writer.venv\Scripts\kickoff.exe_main
.py", line 10, in
File “C:\crewai_project\blog_writer\src\blog_writer\main.py”, line 70, in kickoff
asyncio.run(content_flow.kickoff())
^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init.py”, line 1930, in kickoff
return asyncio.run(run_flow())
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\datta\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py”, line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File “C:\Users\datta\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py”, line 118, in run
return self.loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\datta\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py”, line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 1916, in run_flow
return await self.kickoff_async(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 2222, in kickoff_async
await asyncio.gather(*tasks)
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init.py”, line 2470, in _execute_start_method
await self.execute_listeners(start_method_name, result, finished_event_id)
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 2821, in execute_listeners
await asyncio.gather(*tasks)
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 2952, in _execute_single_listener
listener_result, finished_event_id = await self.execute_method(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 2643, in execute_method
raise e
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\runtime_init
.py", line 2555, in _execute_method
result = await asyncio.to_thread(ctx.run, method, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\datta\AppData\Local\Programs\Python\Python312\Lib\asyncio\threads.py”, line 25, in to_thread
return await loop.run_in_executor(None, func_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\datta\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\flow\flow_wrappers.py”, line 101, in call
return self._meth(self._instance, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer\src\blog_writer\main.py”, line 49, in generate_content
ContentCrew()
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\project\crew_base.py”, line 240, in call
CrewBaseMeta._initialize_crew_instance(instance, cls)
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\project\crew_base.py”, line 252, in _initialize_crew_instance
instance.load_configurations()
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\project\crew_base.py”, line 375, in load_configurations
self.tasks_config = self.load_config(self.original_tasks_config_path, “task”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\project\crew_base.py”, line 353, in load_config
return self.load_yaml(full_path)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\crewai\project\crew_base.py”, line 392, in load_yaml
content = yaml.safe_load(file)
^^^^^^^^^^^^^^^^^^^^
File "C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml_init
.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml_init.py”, line 79, in load
loader = Loader(stream)
^^^^^^^^^^^^^^
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml\loader.py”, line 34, in init
Reader.init(self, stream)
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml\reader.py”, line 85, in init
self.determine_encoding()
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml\reader.py”, line 124, in determine_encoding
self.update_raw()
File “C:\crewai_project\blog_writer.venv\Lib\site-packages\yaml\reader.py”, line 178, in update_raw
data = self.stream.read(size)
^^^^^^^^^^^^^^^^^^^^^^
File “”, line 322, in decode
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x97 in position 1496: invalid start byte
An error occurred while running the flow: Command ‘[‘uv’, ‘run’, ‘kickoff’]’ returned non-zero exit status 1.

To mitigate the error I have taken following measures without result:-

  1. included following code in main.py:-

import sys

import asyncio

#import nest_asyncio

# Patch loops before any CrewAI imports execute

#nest_asyncio.apply()

if sys.platform == ‘win32’:

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  1. replace the code :- content_flow.kickoff() with asyncio.run(content_flow.kickoff())
  2. save all .yml files in utf-8 format and ensured that no fancy character present in these files.

I am stuck here someone kindly help please.

Thanks in advance

FINALLY RESOLVED BY MYSELF, I HAVE GONE THROUGH THE ERROR LOG AND FOUND OUT THAT THE PROBLEM IS IS task.yaml AND THE CHARACTER THAT WAS CREATING THE PROBLEM WAS ‘>’, I OPENED THE task.yaml FILE IN VS CODE EDITOR DELETE AND RE-TYPE THE CHARACTER, AND THATS IT. THANK YOU TO ALL