Skip to content

Instantly share code, notes, and snippets.

@heywin
Last active February 12, 2017 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heywin/65f0f1c9f0fe3d8e2b1a85427155e707 to your computer and use it in GitHub Desktop.
Save heywin/65f0f1c9f0fe3d8e2b1a85427155e707 to your computer and use it in GitHub Desktop.
MacOS下selenium和chromedriver配置
from selenium import webdriver
driver = webdriver.Chrome() 
driver.get('http://www.google.com/xhtml');

出现错误提示

"ChromeDriver executable needs to be available in the path. " selenium.common.exceptions.WebDriverException: Message: ChromeDriver executable needs to be available in the path. Please download from http://chromedriver.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/ChromeDriver

解决办法

vim ~/.bash_profile
export PATH=$PATH:ChromeDriver目录(注意,是存放的目录,不是这个文件)
:wq
source ~/.bash_profile

或者

driver = webdriver.Chrome(path)

一定要是下载下来的webdriver的完整路径

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment