繁体   English   中英

Pyinstaller 在运行 .exe 时给出“'chromedriver.exe' 可执行文件需要在 PATH 中”,但实际的 python 脚本工作正常

[英]Pyinstaller gives “ 'chromedriver.exe' executable needs to be in PATH” when the .exe is ran, but the actual python script works fine

所以我有一个使用 selenium 的 python 脚本,当我运行它时一切正常,但我想把它变成一个 .exe 文件,所以我使用了 pyinstaller。 我制作了规范文件n的东西,但是当我实际运行.exe时,我得到chromedriver.exe' executable needs to be in PATH中,而当我运行python脚本时通常我没有得到它

这是我设置路径的实际 python 脚本的代码片段。

path = os.getcwd()        
    if (browser == 'c'):
        driver_path = path + '//chromedriver_win32//chromedriver.exe'
        options = webdriver.ChromeOptions()
        options.add_argument("--mute-audio")
        if (hidden == 'T'): options.add_argument('headless')
        driver = webdriver.Chrome(executable_path=driver_path, options=options)
    if (browser == 'f'):
        driver_path = path + '//geckodriver-v0.26.0-win64//geckodriver.exe'
        options = webdriver.FirefoxOptions()
        options.add_argument("--mute-audio")
        if (hidden == 'T'): options.add_argument('headless')
        driver = webdriver.Firefox(executable_path=driver_path, options=options)

如果您需要更多代码,请告诉我。

带有 chromepath 的目录不在正确的位置。 确保仔细检查您的目录层次结构。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM