undetected-chromedriver icon indicating copy to clipboard operation
undetected-chromedriver copied to clipboard

AttributeError: 'Chrome' object has no attribute 'service'

Open taytanqbpass opened this issue 3 years ago • 16 comments

Version: undetected-chromedriver 3.0.3 OS: Windows 10 (64 Bit)

Error log: Exception ignored in: <function Chrome.__del__ at 0x000002067EB18700> Traceback (most recent call last): File "undetected_chromedriver\v2.py", line 623, in __del__ File "undetected_chromedriver\v2.py", line 581, in quit AttributeError: 'Chrome' object has no attribute 'service'

Code snippet: import undetected_chromedriver.v2 as uc
driver = uc.Chrome()

Been getting this error lately, have tried updating to 3.0.4 and 3.0.5 but had no luck. Any thoughts on this? Thanks.

taytanqbpass avatar Nov 18 '21 01:11 taytanqbpass

Getting same error on windows 10 (64 Bit) Adding more log..

        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

masudr4n4 avatar Nov 18 '21 15:11 masudr4n4

Including my test program in the main function solved this. Removing it from main() resulted in the errors you both are recieving, for me at least. I also went back to 3.9 since I was experiencing issues with 3.10 that I've not yet explored 100%. ` import undetected_chromedriver.v2 as uc from selenium.webdriver.common.by import By import time def main():

options = uc.ChromeOptions()
options.add_argument("--no-sandbox --no-first-run --no-service-autorun --password-store=basic")
driver = uc.Chrome(options=options, version_main=96)  # version_main allows to specify your chrome version instead of following chrome global version
driver.get('https://login.live.com') 
driver.find_element(By.NAME, "loginfmt").send_keys("[email protected]")
time.sleep(30)
print("Terminated")

if name == "main": main() `

Shpagooder avatar Nov 18 '21 17:11 Shpagooder

same issue under windows, if I run the same code on an ec2 with linux it works. Putting the call inside if name == 'main': fixes the issue but is not a good solution for various cases

koljaoh avatar Nov 19 '21 16:11 koljaoh

Including my test program in the main function solved this. Removing it from main() resulted in the errors you both are recieving, for me at least. I also went back to 3.9 since I was experiencing issues with 3.10 that I've not yet explored 100%. ` import undetected_chromedriver.v2 as uc from selenium.webdriver.common.by import By import time def main():

options = uc.ChromeOptions()
options.add_argument("--no-sandbox --no-first-run --no-service-autorun --password-store=basic")
driver = uc.Chrome(options=options, version_main=96)  # version_main allows to specify your chrome version instead of following chrome global version
driver.get('https://login.live.com') 
driver.find_element(By.NAME, "loginfmt").send_keys("[email protected]")
time.sleep(30)
print("Terminated")

if name == "main": main() `

this kinda worked for me but im struggling on how to implement this in a class

Snuifstuif avatar Nov 19 '21 21:11 Snuifstuif

Greetings !

OS & App info: Python: 3.8.10 - 64 bit Chrome version: 96 Windows: 10 - 64 bit undetected-chromedriver: pip install undetected-chromedriver --upgrade: Requirement already satisfied: undetected-chromedriver in c:\python38\lib\site-packages (3.0.5) Requirement already satisfied: selenium in c:\python38\lib\site-packages (from undetected-chromedriver) (4.0.0) . .

Errors:


Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python38\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python38\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path      
    main_content = runpy.run_path(main_path,
  File "C:\Python38\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Python38\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\Users\linux10\Desktop\ea_project\cdp_listen.py", line 14, in <module>
    driver = uc.Chrome(enable_cdp_events=True)
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 300, in __init__
    self.browser_pid = start_detached(options.binary_location, *options.arguments)
  File "C:\Python38\lib\site-packages\undetected_chromedriver\dprocess.py", line 30, in start_detached
    multiprocessing.Process(
  File "C:\Python38\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python38\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Python38\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python38\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\Python38\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
Exception ignored in: <function Chrome.__del__ at 0x000002771670A430>
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 626, in __del__
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 586, in quit
AttributeError: 'Chrome' object has no attribute 'service'
Traceback (most recent call last):
  File "c:/Users/linux10/Desktop/ea_project/cdp_listen.py", line 14, in <module>
    driver = uc.Chrome(enable_cdp_events=True)
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 300, in __init__
    self.browser_pid = start_detached(options.binary_location, *options.arguments)
  File "C:\Python38\lib\site-packages\undetected_chromedriver\dprocess.py", line 37, in start_detached
    pid = reader.recv()
  File "C:\Python38\lib\multiprocessing\connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "C:\Python38\lib\multiprocessing\connection.py", line 305, in _recv_bytes
    waitres = _winapi.WaitForMultipleObjects(
KeyboardInterrupt
Exception ignored in: <function Chrome.__del__ at 0x000001DB62067A60>
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 626, in __del__
  File "C:\Python38\lib\site-packages\undetected_chromedriver\v2.py", line 586, in quit
AttributeError: 'Chrome' object has no attribute 'service'

alimp5 avatar Nov 20 '21 07:11 alimp5

I also have this issue, got it after reinstalling python

I reinstalled too, but nothing changed, I use python 3.10 now

minh7296 avatar Nov 22 '21 03:11 minh7296

@ minh7296

try to install version 3.0.3 it works fine and without problem with python 3.8.10 on windows 10.

alimp5 avatar Nov 22 '21 12:11 alimp5

Can someone help me?

Snuifstuif avatar Nov 22 '21 13:11 Snuifstuif

@ minh7296

try to install version 3.3.0 it works fine and without problem with python 3.8.10 on windows 10.

Thank you it temporary works , any chance that I can use undetected chromedriver ith latest python version please ?

minh7296 avatar Nov 23 '21 08:11 minh7296

Please merge the pull requests so we can use python 3.10 @ultrafunkamsterdam @TJM4

Duartemartins avatar Nov 25 '21 20:11 Duartemartins

Same issue under windows 10, undetected-chromedriver v3.0.6 and python v3.9.9

Just I upgraded python and undetected-chromedriver but if I rollback get the same error.

error code on python v3.10 and undetected-chromedriver v3.0.6

`Traceback (most recent call last): File "", line 1, in File "C:\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "C:\Python310\lib\multiprocessing\spawn.py", line 125, in _main prepare(preparation_data) File "C:\Python310\lib\multiprocessing\spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Python310\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "C:\Python310\lib\runpy.py", line 269, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Python310\lib\runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Python310\undetected_demo.py", line 2, in driver = uc.Chrome() File "C:\Python310\lib\site-packages\undetected_chromedriver\v2.py", line 299, in init self.browser_pid = start_detached(options.binary_location, *options.arguments) File "C:\Python310\lib\site-packages\undetected_chromedriver\dprocess.py", line 31, in start_detached daemon=True).start() File "C:\Python310\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\Python310\lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Python310\lib\multiprocessing\context.py", line 327, in _Popen return Popen(process_obj) File "C:\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in init prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "C:\Python310\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

Exception ignored in: <function Chrome.del at 0x000001C56C6C8C10> Traceback (most recent call last): File "C:\Python310\lib\site-packages\undetected_chromedriver\v2.py", line 647, in del File "C:\Python310\lib\site-packages\undetected_chromedriver\v2.py", line 604, in quit AttributeError: 'Chrome' object has no attribute 'service'`

deparra avatar Nov 29 '21 19:11 deparra

I found the correct version in windows 10 python = v3.9.9 undetected_chromedriver = 3.0.3

how to install old version in pip?

pip uninstall undetected-chromedriver
pip install -Iv undetected-chromedriver==3.0.3

deparra avatar Nov 29 '21 21:11 deparra

has anyone found a solution for running multiple browsers?

nomie7 avatar Dec 06 '21 19:12 nomie7

I had same problem, when i try lounch more then one driver, and solved it by using different options for every lounch driver: import undetected_chromedriver.v2 as uc options = uc.ChromeOptions() options1 = uc.ChromeOptions() ... driver = uc.Chrome(options=options) driver1 = uc.Chrome(options1=options) ...

K10yn avatar Jan 11 '22 11:01 K10yn

add if __name__ == '__main__':

and start your code

HCWcoder avatar Sep 19 '22 16:09 HCWcoder

use these requirements to create the env https://github.com/AffanAhmedUsmani/Issue-Resolution/blob/main/requirements.txt

AffanAhmedUsmani avatar Oct 17 '23 16:10 AffanAhmedUsmani