0

I'm using a pretty standard boilerplate undetected_chromedriver installation:

LOCAL_CHRPATH = '/opt/google/chrome/chromedriver'
driver = uc.Chrome(
        driver_executable_path=LOCAL_CHRPATH, headless=True
)

However, driver.get(url) simply fails silently, exiting the program. I have looked through the documentation, and found no way to get diagnostics pre or post get. Any idea of what to do or where to check?

You can pretty much ignore the specifics about the path and so on; the real question here is to understand why it fails.

Update: if I set debug to True, I get the same error that's indicated in this SO question. However, don't see a workaround for that. As an indication, this was working correctly with Python 3.10, stopped working when downgrading to 3.9

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
  • does it exit with a code? I mean, do you sen "exit with code -1" or something in the terminal? – NicoCaldo Jul 08 '22 at 11:52
  • @NicoCaldo it's run from poetry, maybe that hides the exit value. But I guess it does, since it's exiting prematurely. Would codes give me some information? – jjmerelo Jul 08 '22 at 12:10
  • it's a first indication on what happened. exit 1 usually is when some sort of error happens – NicoCaldo Jul 08 '22 at 12:14
  • @NicoCaldo I know an error has happened, it simply does not work. I want to know which one. – jjmerelo Jul 08 '22 at 12:15

1 Answers1

0

LOCAL_CHRPATH = '/opt/google/chrome/chromedriver'

This is local variable, not environmental. To set envvar you could:

os.environ["LOCAL_CHRPATH"] = '/opt/google/chrome/chromedriver'

Or just don't use envvars, or set default value:

driver = uc.Chrome(
    driver_executable_path=os.getenv('LOCAL_CHRPATH', LOCAL_CHRPATH), 
    headless=True
)
Raymond Reddington
  • 1,709
  • 1
  • 13
  • 21
  • I know it's confusing to have them both with the same name, but what I do is to set the env variable to 1 and if it's set, use the preset path as the value. The path is set correctly. Maybe I'll just edit to avoid confusion – jjmerelo Jul 08 '22 at 12:07