Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

python - Can't use chrome driver for Selenium

I'm having trouble using the Chrome driver for Selenium. I have the chromedriver downloaded and saved to C:Chrome:

driver = webdriver.Chrome(executable_path="C:/Chrome/")

Using that gives me the following error:

Traceback (most recent call last):
  File "C:Python33libsubprocess.py", line 1105, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:Python33libsite-packagesseleniumwebdriverchromeservice.py", line 63, in start
    self.service_args, env=env, stdout=PIPE, stderr=PIPE)
  File "C:Python33libsubprocess.py", line 817, in __init__
    restore_signals, start_new_session)
  File "C:Python33libsubprocess.py", line 1111, in _execute_child
    raise WindowsError(*e.args)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Wilson/Dropbox/xxx.py", line 71, in <module>
    driver = webdriver.Chrome(executable_path="C:/Chrome/")
  File "C:Python33libsite-packagesseleniumwebdriverchromewebdriver.py", line 59, in __init__
    self.service.start()
  File "C:Python33libsite-packagesseleniumwebdriverchromeservice.py", line 68, in start
    and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.                 Please download from http://chromedriver.storage.googleapis.com/index.html  

Any help would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should specify the executable file path, not the directory path that contains the executable.

driver = webdriver.Chrome(executable_path=r"C:Chromechromedriver.exe")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...