Python selenium 在 mac 下面运行总是报错,求指教!

2018-07-18 15:13:34 +08:00
 bestehen

/usr/local/bin/chromedriver 目录是我 python3 目录

option = webdriver.ChromeOptions() option.add_argument('--start-maximized') # 最大化 option.add_argument('--headless') # 无界面

self.driver = webdriver.Chrome(chrome_options=option) self.phone_number = '15910846849' self.login_url = 'http://auth.qimingpian.com/finos.html' self.report_url='http://vip.qimingpian.com/#/finos/investment/ireport' self.cookies= os.getcwd() + "/" + "cookies"

报错如下: Traceback (most recent call last): File "qimingpian.py", line 119, in <module> qimingpian().get_content() File "qimingpian.py", line 13, in init self.driver = webdriver.Chrome(chrome_options=option) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in init desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 245, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 314, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.39.562713 (dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.12.6 x86_64

2311 次点击
所在节点    Python
2 条回复
brucedone
2018-07-18 15:48:21 +08:00
如果是 mac 呢,你可以考虑装个 docker,然后装 selenium 的 docker 镜像,好用的一 B,教程的话,看这里就可以了,http://brucedone.com/archives/1021
Phant0m
2018-07-18 17:04:01 +08:00
```
cannot find Chrome binary
```
设置下 chrome.app 的路径就好了
options.binary_location = '路径'

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/471998

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX