python - Selenium Chrome 驱动程序显示未指定路径
问题描述
在运行任何硒代码时,它显示了这一点,我什至已将 chromedriver.exe 添加到我的目录中,但仍然出现此错误
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Programming\Python\Projects\_Acoustify_\Scrapping bots\amazon_bot_2.py", line 4, in <module>
driver = webdriver.Chrome()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
解决方案
在错误的最后一行,你必须chromedriver
在 PATH 中。
如果要将其保留在项目目录中,请将路径添加chromedriver
到您的webdriver
调用中:
driver = webdriver.Chrome('/path/to/chromedriver')
推荐阅读
- c# - c#不完整的Console.ReadKey()调用我不希望用户完成
- reactjs - ReactJS: Using state causes error rendering heading
- xaml - 如何从 ListView.ItemTemplate 中访问父视图模型?
- python - 返回多个函数的装饰器
- excel - 从 Excel 打开 Outlook 时如何预先选择电子邮件配置文件?
- javascript - 如何检查数组是否包含来自 vue.js 模板中另一个数组的项目
- flutter - 单选按钮没有改变
- javascript - 当我单击提交按钮时,JS 代码无法执行(或执行任何操作)
- javascript - 在引号中使用变量
- laravel - 如何扩展 Laravel Dusk 浏览器?