Selenium配合chromedriver打包为exe后运行时提示Message chromedriver executable needs to be in PATH

Selenium配合chromedriver提示“Message: ‘chromedriver’ executable needs to be in PATH

使用pyinstaller打包exe文件夹后,执行程序报错,如图

Selenium配合chromedriver打包为exe后运行时提示Message chromedriver executable needs to be in PATH_第1张图片

网上查阅了好多资料,尝试了多种办法

1、chromedriver 版本是否和本机浏览器位置相同(具体对应版本请百度)
2、chromedriver 放在chrome浏览器同级位置(默认安装,位置应该都相同)

C:\Program Files (x86)\Google\Chrome\Application

发现还报错,继续添加

3、错误说缺少PATH嘛,那就添加系统环境变量

我的电脑->右键属性->高级系统设置-> 环境变量->系统环境变量->PATH里面添加chromedriver路径

还是报错

4、python安装目录下的Scripts目录里面添加chromedriver

重新打开exe文件,还是报错。。。

5、那最终咱们就修改代码,chrome路径应该都相同,所以
browser = webdriver.Chrome(options=chrome_options, executable_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe")

你可能感兴趣的:(python)