Details:
Ich verwende browser_use und langchain_openai-Bibliotheken zum Extrahieren und Verarbeiten von Daten.
Der Fehler scheint aufzutreten, wenn das Programm versucht, eine Schriftart mit ImageFont.truetype() zu erstellen.
Hier ist die relevanter Teil meines Codes:
Code: Select all
from langchain_openai import ChatOpenAI
from browser_use import Agent
import asyncio
from dotenv import load_dotenv
import openai
import os
import csv
# Load environment variables from .env file
load_dotenv()
# Initialize OpenAI API key from environment
openai.api_key = os.getenv("OPENAI_API_KEY")
if not openai.api_key:
raise ValueError("OpenAI API key not found. Ensure it's set in the .env file.")
async def main():
agent = Agent(
task="Find non-profit organisations in drc and return the names, location and what they do.",
llm=ChatOpenAI(model="gpt-4o"),
)
result = await agent.run()
print(result)
asyncio.run(main())
Code: Select all
INFO [agent] ✅ Task completed successfully
Traceback (most recent call last):
File "D:\llms\browser_use\app.py", line 26, in
asyncio.run(main())
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\llms\browser_use\app.py", line 22, in main
result = await agent.run()
^^^^^^^^^^^^^^^^^
File "D:\llms\browser_use\venv\Lib\site-packages\browser_use\agent\service.py", line 391, in run
self.create_history_gif()
File "D:\llms\browser_use\venv\Lib\site-packages\browser_use\agent\service.py", line 642, in create_history_gif
task_frame = self._create_task_frame(
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\llms\browser_use\venv\Lib\site-packages\browser_use\agent\service.py", line 709, in _create_task_frame
larger_font = ImageFont.truetype(
^^^^^^^^^^^^^^^^^^^
File "D:\llms\browser_use\venv\Lib\site-packages\PIL\ImageFont.py", line 879, in truetype
return freetype(font)
^^^^^^^^^^^^^^
File "D:\llms\browser_use\venv\Lib\site-packages\PIL\ImageFont.py", line 876, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\llms\browser_use\venv\Lib\site-packages\PIL\ImageFont.py", line 288, in __init__
load_from_bytes(cast(IO[bytes], font))
File "D:\llms\browser_use\venv\Lib\site-packages\PIL\ImageFont.py", line 268, in load_from_bytes
self.font = core.getfont(
^^^^^^^^^^^^^
OSError: cannot open resource