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

Issue creating multiple drivers [ subprocess : TypeError: expected str, bytes or os.PathLike object, not NoneType ] #726

Open
ultrafunkamsterdam opened this issue Jul 14, 2022 · 3 comments
Assignees

Comments

@ultrafunkamsterdam
Copy link
Owner

Actually there seems something wrong using threading.threads and mp.processes, as well as asyncio or even in the main thread

when creating multiple drivers.

I don't know why i even bother since creating multiple drivers is useless and solves no problems.
chromedriver is just a messaging proxy passing messages back and forth. and 1 driver can control dozens of windows, each containing a magnitude of tabs (and is designed for that)

that having said

note: all the below has also been done using the (use_subprocess=True)

in Ipython this works fine:

drivers = [uc.Chrome() for _ in range(20) ]

however, when creating a file:

... 
stuff
...
some other stuff
...

if __name__ == '__main__':

    drivers = [uc.Chrome() for _ in range(10)] 
    input("press a key to exit")

running this file yields:

    browser = subprocess.Popen(
  File "C:\ProgramData\Python39-32\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\ProgramData\Python39-32\lib\subprocess.py", line 1360, in _execute_child
    args = list2cmdline(args)
  File "C:\ProgramData\Python39-32\lib\subprocess.py", line 565, in list2cmdline
    for arg in map(os.fsdecode, seq):
  File "C:\ProgramData\Python39-32\lib\os.py", line 822, in fsdecode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType

thinking of a solution i tried modifying the code to put the path in a class variable when the first instance starts. but of course this won't work as it is not thread-safe.

workaround

So the ONLY solution for now (which is a bit cumbersome, so actually fits perfectly in creating multiple chromedrivers ;))
but does the job i :

putting the full path to your chrome BROWSER executable in the constructor

like so

 drivers = [uc.Chrome(browser_executable_path=r"c:\program files\x\y\z\chrome.exe") for _ in range(135)] 

Raising this as an issue since that is hip

(and I don't yet started documentation, nor know where to start, nor have time). so this is FYI

@ultrafunkamsterdam ultrafunkamsterdam self-assigned this Jul 14, 2022
@ultrafunkamsterdam ultrafunkamsterdam pinned this issue Jul 14, 2022
@RFG-G
Copy link

RFG-G commented Feb 24, 2023

Any solutions?

@thuydao
Copy link

thuydao commented Nov 22, 2023

i am stuck on this

@Raguggg
Copy link

Raguggg commented Jan 20, 2024

Solution:

To address the problem, you can modify the code as follows:

drivers = [
    uc.Chrome(
        version_main=114,  # Specify your browser version
        browser_executable_path="/path/of/chrome",  # Provide the path of the Chrome browser
        driver_executable_path="path/uc/driver",  # Specify the path of the UC driver
    )
    for _ in range(135)
]

To obtain the path of the UC driver, run a single instance chrome using UC. It will create the driver in a specific directory based on your operating system:

Windows: ~/appdata/roaming/undetected_chromedriver
Linux: ~/.local/share/undetected_chromedriver
Adjust the paths accordingly based on your system configuration.

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

4 participants