pydoll icon indicating copy to clipboard operation
pydoll copied to clipboard

ValueError: Browser not found: /usr/bin/google-chrome

Open WittmannF opened this issue 1 year ago • 3 comments

To my understanding, it doesn't require a chrome web-browser. Or am I missing something? Here's the error I got:

/Users/wittmannf/miniconda3/bin/python /Users/wittmannf/repos/misc/with_pydoll.py
Traceback (most recent call last):
  File "/Users/wittmannf/repos/misc/with_pydoll.py", line 8, in main
    await browser.start()
  File "/Users/wittmannf/miniconda3/lib/python3.12/site-packages/pydoll/browser/base.py", line 72, in start
    self.options.binary_location or self._get_default_binary_location()
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wittmannf/miniconda3/lib/python3.12/site-packages/pydoll/browser/chrome.py", line 27, in _get_default_binary_location
    return BrowserOptionsManager.validate_browser_path(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wittmannf/miniconda3/lib/python3.12/site-packages/pydoll/browser/managers.py", line 153, in validate_browser_path
    raise ValueError(f'Browser not found: {path}')
ValueError: Browser not found: /usr/bin/google-chrome

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/wittmannf/repos/misc/with_pydoll.py", line 16, in <module>
    asyncio.run(main())
  File "/Users/wittmannf/miniconda3/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/wittmannf/miniconda3/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wittmannf/miniconda3/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/wittmannf/repos/misc/with_pydoll.py", line 7, in main
    async with Chrome() as browser:
  File "/Users/wittmannf/miniconda3/lib/python3.12/site-packages/pydoll/browser/base.py", line 66, in __aexit__
    await self.stop()
  File "/Users/wittmannf/miniconda3/lib/python3.12/site-packages/pydoll/browser/base.py", line 210, in stop
    raise exceptions.BrowserNotRunning('Browser is not running')
pydoll.exceptions.BrowserNotRunning: The browser is not running

Running the following test on MacOS:

import asyncio
from pydoll.browser.chrome import Chrome
from pydoll.constants import By

async def main():
    # Start the browser with no additional webdriver configuration!
    async with Chrome() as browser:
        await browser.start()
        page = await browser.get_page()
        
        # Navigate through captcha-protected sites without worry
        await page.go_to('https://www.example.com')
        await page.get_screenshot('./ss.png')
        

asyncio.run(main())

WittmannF avatar Mar 08 '25 14:03 WittmannF

It looks like the defaults just have Linux in mind, but you can override the executable location:

async def main():
    # Start the browser with no additional webdriver configuration!
    options = Options()
    options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
    async with Chrome(options=options) as browser:
        ...

isaacwasserman avatar Mar 08 '25 22:03 isaacwasserman

we have an open PR from @CaioWzy to fix this problem also, thanks for opening the issue :)

thalissonvs avatar Mar 09 '25 14:03 thalissonvs

@WittmannF Can you check if it's working now?

thalissonvs avatar Mar 09 '25 14:03 thalissonvs