ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
10.12k stars 1.17k forks source link

FileNotFoundError: [Errno 2] while running multiple instances #1147

Open bharatbots opened 1 year ago

bharatbots commented 1 year ago

I'm running multiple instances with ThreadPoolExecutor and I randomly get this error and the entire program crashes.

I'm on MacOS and using the latest version of UC and Selenium. I also gave a try to @fix-multiple-instance but it didn't work. I ran it on Windows, Linux etc and I got the same error everywhere.

Full traceback:

Traceback (most recent call last):
  File "/Users/bharat/Documents/Email Extractor/prod_queue.py", line 265, in <module>
    results = [
  File "/Users/bharat/Documents/Email Extractor/prod_queue.py", line 266, in <listcomp>
    future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/bharat/Documents/Email Extractor/prod_queue.py", line 217, in process_url_chunk
    driver = uc.Chrome(options=options, headless=True, patcher_force_close=True)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 246, in __init__
    self.patcher.auto()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 127, in auto
    self.unzip_package(self.fetch_package())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 180, in unzip_package
    os.rename(os.path.join(self.zip_path, self.exe_name), self.executable_path)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/bharat/Library/Application Support/undetected_chromedriver/undetected/chromedriver' -> '/Users/bharat/Library/Application Support/undetected_chromedriver/undetected_chromedriver'

Not sure if it matters but i'm also using different user-data-dirs for all drivers. I run around 5-6 drivers at the same time. I don't exceed my CPU core limit. I have tried many things suggested from similar issues here but nothing worked.

Heck I event went back to 3.2.0 and it didn't work either. I don't know what to do. Do i need to pre-download uc chromedriver and then put a separate driver path for each uc.Chrome instance?

soft-top-notch commented 1 year ago

Please download the Chromedriver first and then set the pre-downloaded chromedriver path in the driver_executable_path when creating the Chrome instance like so:

driver = Chrome(driver_executable_path=/path/to/chromedriver, options=options)

Then, it will start working fine.