1

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

1
  • You probably have mismatched versions of @playwright/test and playwright Commented Apr 3 at 19:07

1 Answer 1

0

I was able to "fix" this by copying .cache/ms-playwright/chromium-1161 to .cache/ms-playwright/chromium-1155

Playwright is just looking for the chrome.exe. As long as it can find it, it runs fine.

YMMV. This doesn't seem like a proper fix, but it worked for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.