You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After doing pip install, I get a runtime issue from the suggested set up code with the following message:
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
Everything works just fine using the name = main wrapper with the suggested code:
import undetected_chromedriver as uc
if __name__ == '__main__':
driver = uc.Chrome()
driver.get('https://nowsecure.nl')
Without the if statement the runtime error is thrown! A little bit out of practice with the python multiprocessing library, but kind of confused because I thought this was a multiprocessing issue for Windows and I'm on macOS, but it works now so all's well that ends well, I guess.
If anyone else gets this error, hopefully the if main wrapper fixes it for you :)
This has already been covered (multiple times) in previous issues. #384, #519, #570.
As far as I understand, it's also possible to leave out the main wrapper by using the use_subprocess=True under uc.Chrome() options, but security-wise this is the better approach.
In order to create a detached Chrome browser process, undetected-chromedriver use multiprocessing.Process()here which actually spawns a process : in this case Python actually needs to create a new interpreter instance and re-import the code.
That's why you need to wrap your code with an if-clause to protect the code from executing multiple times.
Please check this answer and try it on your own why that's obviously needed.
After doing pip install, I get a runtime issue from the suggested set up code with the following message:
Everything works just fine using the name = main wrapper with the suggested code:
Without the if statement the runtime error is thrown! A little bit out of practice with the python multiprocessing library, but kind of confused because I thought this was a multiprocessing issue for Windows and I'm on macOS, but it works now so all's well that ends well, I guess.
If anyone else gets this error, hopefully the if main wrapper fixes it for you :)
MACHINE INFO:
System: macOS 12.1
Chrome: 100.0.4896.127
Python: 3.9.6
undetected-chromedriver: 3.1.5.post4
The text was updated successfully, but these errors were encountered: