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
9.19k stars 1.1k forks source link

Unable compile with .exe using Pyinstaller after 3.0.6 #608

Open colbyhill21 opened 2 years ago

colbyhill21 commented 2 years ago

First off, I wanted to say thank you for creating this, It has been excellent!

My issue: I am required to bundle UC with Pyinstaller to build it as a .EXE file. I recently have been trying to upgrade from 3.0.6 to take advantage of all of the new improvements, however, this has proven to be quite difficult for my use case due to freezing / crashing when built with pyinstaller. I've seen other issues related to this such as #501, #581 although no resolution has been provided there. I've tried using the workaround mentioned in #581 which is to use freeze_support before importing undetected-chromedriver.

Simple code to reproduce:

from time import sleep
import undetected_chromedriver as uc

if __name__ == '__main__':
    print("Starting now")
    driver = uc.Chrome()

    driver.get('https://google.com')

    print("Opened Google. Closing in 300 seconds.")
    sleep(300)
    driver.quit()

Pyinstaller build command: pyinstaller --noconfirm --onefile --console --add-data "C:/Users/testuser/AppData/Local/Programs/Python/Python310/Lib/site-packages/selenium;selenium/" "C:/Users/testuser/Documents/test/scratch.py"

undetected-chromedriver versions attempted to use:

The last working version is 3.0.6.

I'd greatly appreciate any help with this issue, and would be willing to pay.

voxvici commented 2 years ago

Same issue here, undetected-chromedriver is spawning infinite processes

colbyhill21 commented 2 years ago

@voxvici I am hoping there is a solution for this, I would love to take advantage of the datadome improvements. I've tried digging into the source code although I'm in a bit over my head.

sebdelsol commented 2 years ago

Please check the multiprocessing documentation for freeze_support() here.

sebdelsol commented 2 years ago

@colbyhill21 does freeze_support() fix your issue ?

from multiprocessing import freeze_support
import undetected_chromedriver as uc

if __name__ == '__main__':
    # Add support for when a program which uses multiprocessing has been frozen to produce a Windows executable. 
    # (Has been tested with py2exe, PyInstaller and cx_Freeze.)
    freeze_support()  
    driver = uc.Chrome()
ThomasTrovon commented 2 years ago

@colbyhill21 does freeze_support() fix your issue ?

from multiprocessing import freeze_support
import undetected_chromedriver as uc

if __name__ == '__main__':
    # Add support for when a program which uses multiprocessing has been frozen to produce a Windows executable. 
    # (Has been tested with py2exe, PyInstaller and cx_Freeze.)
    freeze_support()  
    driver = uc.Chrome()

This Worked here. Thanks a lot friend. New problem now. #623 I go there now.. haha