我最近把我的mac电脑升级到OS Catalina(v 10.15.3)。在这次升级之后,我无法使用硒启动chrome驱动程序。
当我运行selenium代码启动chrome浏览器时,我面临以下错误。
“chromedriver”无法打开,因为开发人员无法验证”。 “macOS无法验证此应用程序没有恶意软件。”
请帮帮我!
我最近把我的mac电脑升级到OS Catalina(v 10.15.3)。在这次升级之后,我无法使用硒启动chrome驱动程序。
当我运行selenium代码启动chrome浏览器时,我面临以下错误。
“chromedriver”无法打开,因为开发人员无法验证”。 “macOS无法验证此应用程序没有恶意软件。”
请帮帮我!
当前回答
Xattr -d com.apple.quarantine $(chromedriver)本身是不够的。
对于最新版本的chromedriver,似乎他们正在划分版本文件夹。 9月30日20日给我。对我有用的是xattr -d com.apple.quarantine 85.0.4183.87/chromedriver
其他回答
1.导航到chromedriver文件所在的路径 2.右键单击chromedriver 3.使用终端打开 运行你的代码
我发现,如果你尝试过这个解决方案:
// Get the path to chromedriver, example: /usr/local/bin/chromedriver
which chromedriver
// Change permissions
xattr -d com.apple.quarantine <path_to_chromedriver>
你的浏览器打开后又立即关闭,这可能是因为安装了错误的chromedriver版本。
寻找你的chrome版本启动chrome然后选择
Chrome > About Google Chrome
删除您当前的chromedriver,并在“关于谷歌chrome”中搜索与您的chrome版本匹配的chromedriver(例如:96.0.4664.110)。我用的是一台安装了Monterey操作系统的mac电脑
在M1 mac上安装webdriver-manager的困难更新:
我正在运行一个ARM64 conda miniforge3 env,想知道webdriver_manager安装问题是否可能缺少支持/兼容性,就像这里讨论的Mozilla geckodriver一样。虽然车手似乎已经增加了对M1的支持,但似乎还有一些尚未解决的问题(见这里)。
不管怎样,手动安装ChromeDriver很容易:
有Chrome安装>下载相应的驱动版本 (例如,106)从 ChromeDriver 将它添加到$PATH中,即将shell文件粘贴到$PATH所在的位置,例如,/usr/local/bin/,或者通过命令行:
echo $PATH
export PATH=$PATH:/path/to/chrome-driver
PS:在开始驾驶之前,您必须以管理员身份运行一次驱动程序文件。如果你的Mac不相信驱动文件,按Ctrl+单击并打开。
The above answers were helpful. I would just add that if you're running Selenium from a development environment, in my case a Jupyter Notebook, and this is the issue, you're likely to see a PermissionError: [Errno 13] Permission denied error. There are other causes for this error, but it can be that macOS Catalina is blocking chromedriver from running for security reasons. Following the approaches above, I ran it from the command line and then was able to open it from Jupyter using driver = webdriver.Chrome('path/to/chromedriver).
打开终端,进入下载chromedriver的路径。 执行xattr -d com.apple.quarantine chromedriver