Traceback (most recent call last):
File "D:\Users\HMM77\PycharmProjects\pythonProject0429\0506test01.py", line 5, in <module>
driver=webdriver.Firefox()
^^^^^^^^^^^^^^^^^^^
File "D:\Users\HMM77\anaconda3\envs\pytorch\Lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "D:\Users\HMM77\anaconda3\envs\pytorch\Lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
将版本换成4.10.0后 报错如下
Traceback (most recent call last):
File "D:\Users\HMM77\PycharmProjects\pythonProject0429\0506test01.py", line 5, in <module>
driver=webdriver.Firefox(executable_path='D:\ceshistudy\geckodriver.exe')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'
删掉执行路径还是报错
怀疑是代码有问题
终于成功了!!!!
火狐是最新版的125
驱动器用的33版本
selenium用的是4.20.0
测试代码
from time import sleep
from selenium import webdriver
# driver=webdriver.Firefox(executable_path='D:\ceshistudy\geckodriver.exe')
driver=webdriver.Firefox()
driver.get('http://www.baidu.com')
sleep(10)
driver.quit()
跑通了!!
具体安装教程参考