Traceback (most recent call last): File "cesu.py", line 16, in <module> driver = webdriver.Chrome(executable_path=chromedriver_path, chrome_options=chrome_options) File "C:\python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__ self.service.start() File "C:\python27\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x0000000002EF7C88>> ignored 依然报错
时间: 2023-12-04 10:05:57 浏览: 171
这个错误是由于没有将ChromeDriver添加到系统的环境变量中造成的。要解决这个问题,你可以按照以下步骤进行操作:
1. 首先,确认你已经下载了与你使用的Chrome浏览器版本相对应的ChromeDriver。你可以在这里下载ChromeDriver:https://sites.google.com/a/chromium.org/chromedriver/downloads
2. 将下载好的ChromeDriver解压缩到一个合适的位置。
3. 然后,将ChromeDriver所在目录添加到系统的环境变量中。具体步骤如下:
- 在Windows系统中,右键点击“计算机”或者“此电脑”,选择“属性”。
- 点击“高级系统设置”。
- 在弹出的窗口中,点击“环境变量”按钮。
- 在“系统变量”部分找到名为“Path”的变量,双击打开。
- 点击“新建”按钮,将ChromeDriver所在目录的路径添加进去。
- 点击“确定”保存修改。
4. 最后,重新运行你的代码,应该就能够成功启动ChromeDriver了。如果还有其他问题,请随时向我提问。
阅读全文