I'm trying to use an llm ollama in python (vscode) to scrape data from a website. But whenever I run the code it gives an error: ERROR [browser] Failed to initialize Playwright browser: BrowserType.launch: Executable doesn't exist at C:\Users\yourUser\AppData\Local\ms-playwright\chromium-1155\chrome-win\chrome.exe
The version stored in my director is chromium-1161. Could a mismatched version be the problem? And within the directory - C:\Users\yourUser\AppData\Local\ms-playwright\chromium-1161\chrome-win\ - I cannot find chrome.exe even though I have reinstalled playwright.
Code:
from langchain_community.chat_models import ChatOllama
from browser_use import Agent, Browser, BrowserConfig
from pydantic import SecretStr
import os
import asyncio
import getpass
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("GEMINI_API_KEY")
task = f"""
# Instructions...
"""
# Initialize the model
llm = ChatOllama(model="mistral", api_key=SecretStr(os.getenv('GEMINI_API_KEY')))
browser = Browser()
async def main():
agent = Agent(
task=task,
llm=llm,
)
await agent.run()
input("Press Enter to continue...")
await browser.close()
asyncio.run(main())
Error: INFO [agent] 📍 Step 1 ERROR [browser] Failed to initialize Playwright browser: BrowserType.launch: Executable doesn't exist at C:\Users\yourUser\AppData\Local\ms-playwright\chromium-1155\chrome-win\chrome.exe
@playwright/testandplaywright