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

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

Open
taytanqbpass opened this issue Nov 18, 2021 · 16 comments
Open

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

taytanqbpass opened this issue Nov 18, 2021 · 16 comments

Comments

@taytanqbpass
Copy link

taytanqbpass commented Nov 18, 2021

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.

@masudr4n4
Copy link

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()
                ...

@Shpagooder
Copy link

Shpagooder commented Nov 18, 2021

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()
`

@koljaoh
Copy link

koljaoh commented Nov 19, 2021

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

@Snuifstuif
Copy link

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

@alimp5
Copy link

alimp5 commented Nov 20, 2021

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'

@minh7296
Copy link

I also have this issue, got it after reinstalling python

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

@alimp5
Copy link

alimp5 commented Nov 22, 2021

@ minh7296

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

@Snuifstuif
Copy link

Can someone help me?

@minh7296
Copy link

@ 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 ?

@Duartemartins
Copy link

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

@deparra
Copy link

deparra commented Nov 29, 2021

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
Copy link

deparra commented Nov 29, 2021

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

@nomie7
Copy link

nomie7 commented Dec 6, 2021

has anyone found a solution for running multiple browsers?

@K10yn
Copy link

K10yn commented Jan 11, 2022

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)
...

@HCWcoder
Copy link

add
if __name__ == '__main__':

and start your code

@AffanAhmedUsmani
Copy link

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

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

14 participants