title: Use selenium with chromedriver on Mac
body: <p>I want to use selenium with chromedriver on Mac,but I have some troubles on it.</p>
  
  <ol>
  <li>I download the chromedriver from <a href="https://sites.google.com/a/chromium.org/chromedriver/home" rel="noreferrer">ChromeDriver - WebDriver for Chrome</a></li>
  <li>But I don't want to put it to PATH.So I do this.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/iz0kG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iz0kG.png" alt="enter image description here"></a></p>
  
  <pre><code>import os
  
  from selenium import webdriver
  
  PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
  DRIVER_BIN = os.path.join(PROJECT_ROOT, "bin/chromedriver_for_mac")
  print DRIVER_BIN
  browser = webdriver.Chrome(DRIVER_BIN)
  browser.get('http://www.baidu.com/')
  </code></pre>
  
  <p>But I can't get the result I want.</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/wyx/project/python-scraping/se/test.py", line 15, in &lt;module&gt;
      browser = webdriver.Chrome(DRIVER_BIN)
    File "/Users/wyx/project/python-scraping/.env/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
      self.service.start()
    File "/Users/wyx/project/python-scraping/.env/lib/python2.7/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_for_mac' 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 &lt;bound method Service.__del__ of &lt;selenium.webdriver.chrome.service.Service object at 0x107f96150&gt;&gt; ignored
  </code></pre>
  
  <ol start="3">
  <li><p>Then I run <code>brew cask install chromedriver</code>.And I only run this 
  without the driver path.</p>
  
  <pre><code>browser = webdriver.Chrome()
  browser.get('http://www.baidu.com/')
  </code></pre></li>
  </ol>
  
  <p>But it can't work either.</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/wyx/project/python-scraping/se/test.py", line 16, in &lt;module&gt;
      browser = webdriver.Chrome()
    File "/Users/wyx/project/python-scraping/.env/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
      self.service.start()
    File "/Users/wyx/project/python-scraping/.env/lib/python2.7/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' 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 &lt;bound method Service.__del__ of &lt;selenium.webdriver.chrome.service.Service object at 0x105c08150&gt;&gt; ignored
  
  Process finished with exit code 1
  </code></pre>
  
  <p>Finally I try to put it to /usr/bin</p>
  
  <pre><code>➜  Downloads sudo cp chromedriver /usr/bin
  Password:
  cp: /usr/bin/chromedriver: Operation not permitted
  </code></pre>
  
  <p>and I try to use <code>export PATH=$PATH:/Users/wyx/project/python-scraping/se/bin/chromedriver_for_mac</code> in .zshrc . But </p>
  
  <blockquote>
    <p>selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.</p>
  </blockquote>
  
  <p>So how to solve it，I want to use it with the driver path not in the PATH so I can deploy my project easily.</p>
  
  <p>Solution:</p>
  
  <ol>
  <li><code>brew cask install chromedriver</code></li>
  <li><code>which chromedriver</code> get the driver path</li>
  <li>And then use it like this <code>webdriver.Chrome("/usr/local/bin/chromedriver")</code></li>
  </ol>
  
  <blockquote>
    <p>But I don't know why so complex to use selenium.</p>
  </blockquote>