这个问题在这里已有答案:

我是python的新手,我在运行webdriver时遇到问题

当我运行以下代码时:

chromedriver ='C:/ to / path / chromedriver'driver = webdriver.Chrome(chromedriver)

我收到以下错误:

回溯(最近一次调用最后一次):文件"/Users/danielaphilipson/Documents/EPoD/env/lib/python3.6/site-packages/selenium/webdriver/common/service.py",第76行,在start stdin = PIPE中)文件"/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py",第709行,在 init restore_signals,start_new_session中)文件"/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py",第1344行,在_execute_child中引发child_exception_type(errno_num,err_msg,err_filename)FileNotFoundError :[Errno 2]没有这样的文件或目录:'C:/to/path/chromedriver':'C:/to/path/chromedriver'

在处理上述异常期间,发生了另一个异常:

回溯(最近一次调用最后一次):文件“”,第1行,在文件“/Users/.../lib/python3.6/site-??>>packages/selenium/webdriver/chrome/webdriver.py” ,第68行,在init self.service.start()文件“/Users/.../lib/python3.6/site->>packages/selenium/webdriver/common/service.py”,第83行,开始os.path.basename(self.path),self.start_error_message)selenium.common.exceptions.WebDriverException:消息:'chromedriver'>>可执行文件需要在PATH中 . 请参阅>> https://sites.google.com/a/chromium.org/chromedriver/home

对于如何解决这个问题,有任何的建议吗?