webcrawler icon indicating copy to clipboard operation
webcrawler copied to clipboard

'chromedriver' executable needs to be in PATH

Open HisenZhang opened this issue 7 years ago • 2 comments

I am not familiar with bs4. What is this case about? Or let me ask, what is 'chromedrive'?

Traceback (most recent call last):
  File "girls_crawler_py27.py", line 87, in <module>
    main()
  File "girls_crawler_py27.py", line 20, in main
    driver = webdriver.Chrome()   # open with Chrome
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 81, 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

HisenZhang avatar Aug 28 '17 03:08 HisenZhang

有个简单的解决办法,把下面行的代码稍作改动

driver = webdriver.Chrome()   # 打开浏览器

在webdrive.chrome的参数里写上你下载好的chromedriver的绝对路径,比如 driver = webdriver.Chrome('/Users/(****你的用户名)/chromedriver') # 打开浏览器

lietouleon avatar Aug 29 '17 04:08 lietouleon

把chromedriver放到环境变量path下任意一个路径中,或者你把chromedriver的路径添加到环境变量path中即可

fff2zrx avatar Aug 12 '19 15:08 fff2zrx