5
Exception ignored in: <function Chrome.__del__ at 0x00000241BFF44360>
Traceback (most recent call last):
  File "C:\Users\kevin\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 769, in __del__
  File "C:\Users\kevin\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 758, in quit
OSError: [WinError 6] The handle is invalid

The code runs without error through python console and I just wanna know if there is anyway to run the code without running it through the python console. My python version is 3.1.1., Chrome is the lastest version, and undetected chrome driver is also the lastest version.

import undetected_chromedriver.v2 as uc
driver = uc.Chrome()
driver.get('https://nowsecure.nl')

This is the code that I found from the undetected chromedriver github.

2 Answers2

1

You can avoid this problem by modifying code in the undetected_chromedriver\__init__.py.

Go to line 755 and wrap the time.sleep(0.1) with try-except block here is how the final code look like

try:
  time.sleep(0.1)
except OSError:
  pass
i-naeem
  • 21
  • 4
0

Are you using driver.close() or driver.quit() try changing between them and see if that helps. In my case, I changed it to driver.close() and it works. Python: 3.11