V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

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

  •  
  •   bestehen · 2018-07-18 15:13:34 +08:00 · 2315 次点击
    这是一个创建于 2353 天前的主题,其中的信息可能已经有所发展或是发生改变。

    /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

    brucedone
        1
    brucedone  
       2018-07-18 15:48:21 +08:00
    如果是 mac 呢,你可以考虑装个 docker,然后装 selenium 的 docker 镜像,好用的一 B,教程的话,看这里就可以了,http://brucedone.com/archives/1021
    Phant0m
        2
    Phant0m  
       2018-07-18 17:04:01 +08:00
    ```
    cannot find Chrome binary
    ```
    设置下 chrome.app 的路径就好了
    options.binary_location = '路径'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1043 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 20:05 · PVG 04:05 · LAX 12:05 · JFK 15:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.