'chromedriver' executable needs to be in PATH
我是Mac系统,chrome Version 80.0.3987.149 (Official Build) (64-bit),下了80.0.3987.16也解压在/usr/local/bin里面了from selenium import webdriver
browser=webdriver.Chrome()
browser.get('http://www.baidu.com/')
WebDriverException: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 把 chromedriver 添加到环境变量中试试 给你看个教程:
http://www.python3.vip/tut/auto/selenium/01/ 本帖最后由 1q23w31 于 2020-8-7 22:11 编辑
https://blog.csdn.net/tinyDolphin/article/details/86362617
mac添加环境变量的方法 1q23w31 发表于 2020-8-7 21:07
https://blog.csdn.net/tinyDolphin/article/details/86362617
mac添加环境变量的方法
请问确保 ~/.bash_profile 中已经加入 export PATH=/usr/local/bin:$PATH这个是啥意思 非洲小土著 发表于 2020-8-7 23:00
请问确保 ~/.bash_profile 中已经加入 export PATH=/usr/local/bin:$PATH这个是啥意思
在~/.bash_profile 中输入 export PATH=/usr/local/bin:/usr/local/bin/chromedriver 这是 selenium 用法的实例,希望对你有帮助,有什么不懂的再问我,由于这段代码是整个程序中有关 selenium 的一段,所以不能直接执行。
from selenium.webdriver import Chrome
from selenium.webdriver import ChromeOptions
import global_control
def _open_explorer(self,url,sign=1):
while True:
try:
chrome_options = ChromeOptions()
chrome_options.add_argument('--disable-gpu')
chrome_options.binary_location = global_control.base_dir+'Plug-in\\Google\\Chrome\\Application\\chrome.exe'
chrome_options.add_argument(self.user_data)
exec(f"chrome_driver{sign} = Chrome(options=chrome_options,executable_path=global_control.base_dir+'Plug-in\\chromedriver.exe')")
break
except:
sign += 1
exec(f"chrome_driver{sign}.get(url)")
try:
while eval(f'chrome_driver{sign}.title'):
if global_control.break_program or self.sign in global_control.break_program_number:raise ImportError
sleep(1)
except:
exec(f"chrome_driver{sign}.quit()")
页:
[1]