【问题标题】:RuntimeError when using undetected_chromedriver使用 undetected_chromedriver 时出现 RuntimeError
【发布时间】:2022-07-19 05:11:27
【问题描述】:

这是我的脚本(这是您可以在 https://github.com/ultrafunkamsterdam/undetected-chromedriver 找到的示例):

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

我收到此错误:

RuntimeError       (note: full exception trace is shown but execution is paused at: <module>)

        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
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.   File "D:\Users\Mark\python scripts\test_2.py", line 2, in <module> (Current frame)
    driver = uc.Chrome()   File "<string>", line 1, in <module>

我该如何解决这个问题?

【问题讨论】:

  • 我不确定这是否相关,但这是否与 here 相同的错误?
  • @CmdCoder858 是的,看起来是一样的。但是,我认为它是由模块生成的,而不是由我的代码生成的。
  • 好的,所以我没有 chromedriver 可执行文件,但我测试了代码并在主代码块周围添加 if __name__ == "__main__": 会使错误发生变化,因此这可能是您正在寻找的修复程序。此外,如果没有这个,似乎 README 文件中的示例也会失败,因此提出问题以便可以更新可能是个好主意。

标签: python undetected-chromedriver


【解决方案1】:

尝试添加参数:

驱动程序 = uc.Chrome(use_subprocess=True)

查找https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/384

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 2020-05-21
    • 2022-08-06
    • 1970-01-01
    • 2019-08-18
    相关资源
    最近更新 更多