Python Selenium“'geckodriver'可执行文件需要在路径中”

2024-04-25 17:21:11 发布

您现在位置:Python中文网/ 问答频道 /正文

即使我已经把geckodriver放在那里,我重新启动了我的电脑,它仍然打印出同样的东西。在

>>>from selenium import webdriver
>>>browser = webdriver.Firefox()
Traceback (most recent call last):
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "D:\Python\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "D:\Python\lib\subprocess.py", line 992, in _execute_child
startupinfo)
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 "<stdin>", line 1, in <module>
File "D:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in __init__
self.service.start()
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

在此之前还有一个错误!有人帮个新手吧。Image of the Path variable


Tags: theinpyselflibpackagesseleniumservice
1条回答
网友
1楼 · 发布于 2024-04-25 17:21:11

您需要提到gecko驱动程序可执行文件的路径。下面这条线会让你有一些想法。在

driver=webdriver.Firefox(executable_path="add geckodriver.exe")

希望这有帮助。谢谢。在

相关问题 更多 >