Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google colab Service ./chromedriver unexpectedly exited. Status code was: -6 #163

Closed
domindominik opened this issue May 2, 2021 · 4 comments

Comments

@domindominik
Copy link

hi
my code:

!apt-get update
!pip install undetected-chromedriver
import undetected_chromedriver as uc

url = 'https://allegro.pl/oferta/dr-coffee-f12-big-plus-ekspres-do-kawy-10196811305#aboutSeller'
options = uc.ChromeOptions('/usr/bin/chromedriver')
options.headless=True
options.add_argument('--headless')
chrome = uc.Chrome(options=options)
chrome.get(url)

print(chrome.page_source)

after running my code, I get the folowing error:

WebDriverException                        Traceback (most recent call last)
<ipython-input-4-014d209fefad> in <module>()
      5 options.headless=True
      6 options.add_argument('--headless')
----> 7 chrome = uc.Chrome(options=options)
      8 chrome.get(url)
      9 

3 frames
/usr/local/lib/python3.7/dist-packages/undetected_chromedriver/__init__.py in __new__(cls, emulate_touch, *args, **kwargs)
     51             kwargs["options"] = ChromeOptions()
     52         instance = object.__new__(_Chrome)
---> 53         instance.__init__(*args, **kwargs)
     54 
     55         instance._orig_get = instance.get

/usr/local/lib/python3.7/dist-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
     71             service_args=service_args,
     72             log_path=service_log_path)
---> 73         self.service.start()
     74 
     75         try:

/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)
     96         count = 0
     97         while True:
---> 98             self.assert_process_still_running()
     99             if self.is_connectable():
    100                 break

/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
    109             raise WebDriverException(
    110                 'Service %s unexpectedly exited. Status code was: %s'
--> 111                 % (self.path, return_code)
    112             )
    113 

WebDriverException: Message: Service ./chromedriver unexpectedly exited. Status code was: -6

how can I run undetected-chromedriver on google colab environment?

@ultrafunkamsterdam
Copy link
Owner

/usr/bin/chromedriver may not be writable. Just dont specify it. Dont specify options.headless AND add_argument("---headless"), it causes double headless in the args to chrome. Idk if colab is supported anyways. Also recommend using v2, and start with bare minimum as shown in readme, first usage entry. For headless pass UC.Chrome(headless=True) (or use options for that).

@domindominik
Copy link
Author

@ultrafunkamsterdam
Before I used v1 code, I have tried to run v2 code

!apt update
!pip install undetected-chromedriver

import undetected_chromedriver.v2 as uc

url = 'https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/'
driver = uc.Chrome()
with driver:
  driver.get(url)

print(driver.page_source)

error:

TypeError                                 Traceback (most recent call last)
<ipython-input-2-318a3e6efcbf> in <module>()
      5 
      6 url = 'https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/'
----> 7 driver = uc.Chrome()
      8 with driver:
      9   driver.get(url)

3 frames
/usr/local/lib/python3.7/dist-packages/undetected_chromedriver/v2.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, keep_alive, log_level, headless, emulate_touch, delay)
    299             stdin=subprocess.PIPE,
    300             stdout=subprocess.PIPE,
--> 301             stderr=subprocess.PIPE,
    302         )
    303 

/usr/lib/python3.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    798                                 c2pread, c2pwrite,
    799                                 errread, errwrite,
--> 800                                 restore_signals, start_new_session)
    801         except:
    802             # Cleanup if the child failed starting.

/usr/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1463                     else:
   1464                         env_list = None  # Use execv instead of execve.
-> 1465                     executable = os.fsencode(executable)
   1466                     if os.path.dirname(executable):
   1467                         executable_list = (executable,)

/usr/lib/python3.7/os.py in fsencode(filename)
    810         'mbcs' (which is the default encoding).
    811         """
--> 812         filename = fspath(filename)  # Does type-checking of `filename`.
    813         if isinstance(filename, str):
    814             return filename.encode(encoding, errors)

TypeError: expected str, bytes or os.PathLike object, not NoneType

after running following code:

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://distilnetworks.com')

I get below error:

Message: Service ./chromedriver unexpectedly exited. Status code was: -6

how to deal with it?

@ultrafunkamsterdam
Copy link
Owner

This looks almost like there is no chrome installation (at least not one installed in a common location). Google may even block it just as they do on GPU misuse. But I'm not here to support all kinds of exotic environments. Buy a PC and off you go 😁

@FloatingMind12
Copy link

Have a look at #108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants