kaliiiiiiiiii / undetected-playwright-python

Undetected Python version of the Playwright testing and automation library.
https://playwright.dev/python/
Apache License 2.0
110 stars 13 forks source link

`executable_path` is different between 'undetected-playwright-python' and 'playwright-python ' #13

Open LeMoussel opened 2 months ago

LeMoussel commented 2 months ago

System info

With this Python test file I got the error below. I don't have this error with the Playwright module

from undetected_playwright.sync_api import sync_playwright
    with sync_playwright() as p:
       browser = p.chromium.launch_persistent_context(user_data_dir=user_data_dir, headless=False)
       page = browser.new_page()
       page.goto('https://playwright.dev/python', wait_until='domcontentloaded')
       browser.close()
Traceback (most recent call last):
  File "/home/dev/Python/Crawlsaurus/./parallel_crawl.py", line 41, in <module>
    browser = p.chromium.launch_persistent_context(user_data_dir=user_data_dir, headless=False)
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/sync_api/_generated.py", line 15065, in launch_persistent_context
    self._sync(
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/_impl/_sync_base.py", line 115, in _sync
    return task.result()
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/_impl/_browser_type.py", line 171, in launch_persistent_context
    from_channel(await self._channel.send("launchPersistentContext", params)),
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/_impl/_connection.py", line 63, in send
    return await self._connection.wrap_api_call(
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/_impl/_connection.py", line 495, in wrap_api_call
    return await cb()
  File "/home/dev/.local/lib/python3.10/site-packages/undetected_playwright/_impl/_connection.py", line 101, in inner_send
    result = next(iter(done)).result()
undetected_playwright._impl._errors.Error: Executable doesn't exist at /home/dev/.cache/ms-playwright/chromium-1091/chrome-linux/chrome
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated.       ║
║ Please run the following command to download new browsers: ║
║                                                            ║
║     playwright install                                     ║
║                                                            ║
║ <3 Playwright Team                                         ║
╚════════════════════════════════════════════════════════════╝

In /home/dev/.cache/ms-playwright/ there is no chromium-1091 directory but the chromium-1112 directory.

from playwright.sync_api import sync_playwright
    with sync_playwright() as p:
        print(p.chromium.executable_path)

Got /home/dev/.cache/ms-playwright/chromium-1112/chrome-linux/chrome

from undetected_playwright.sync_api import sync_playwright
    with sync_playwright() as p:
        print(p.chromium.executable_path)

Got /home/dev/.cache/ms-playwright/chromium-1091/chrome-linux/chrome

vanrohan commented 1 month ago

I had a similar issue, but just passed the executable_path explicitly:

browser = p.chromium.launch(
        executable_path="/home/xxxxx/.cache/ms-playwright/chromium-1117/chrome-linux/chrome",
        args=args,
        headless=False,
    )

or you can install the expected version by running undetected-playwright install

pim97 commented 2 weeks ago
browser = p.chromium.launch(
        channel="chrome",
        args=args,
        headless=False,
    )

worked for me