你好,想請問安裝了chromedriver, 放在和文件同一個資料夾了,還是出現 WebDriverException: Message: 'chromedriver' executable needs to be in PATH,請問是甚麼原因呢?
browser = webdriver.Chrome(executable_path='chromedriver')
browser.get("https://hahow.in/courses")
-----
FileNotFoundError Traceback (most recent call last)
/srv/conda/envs/notebook/lib/python3.7/site-packages/selenium/webdriver/common/service.py in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
/srv/conda/envs/notebook/lib/python3.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
799 errread, errwrite,
--> 800 restore_signals, start_new_session)
801 except:
/srv/conda/envs/notebook/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1550 err_msg += ': ' + repr(err_filename)
-> 1551 raise child_exception_type(errno_num, err_msg, err_filename)
1552 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
<ipython-input-5-a1aece70cfe3> in <module>
----> 1 browser = webdriver.Chrome(executable_path='chromedriver')
2 browser.get("https://hahow.in/courses")
/srv/conda/envs/notebook/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
71 service_args=service_args,
72 log_path=service_log_path)
---> 73 self.service.start()
74
75 try:
/srv/conda/envs/notebook/lib/python3.7/site-packages/selenium/webdriver/common/service.py in start(self)
81 raise WebDriverException(
82 "'%s' executable needs to be in PATH. %s" % (
---> 83 os.path.basename(self.path), self.start_error_message)
84 )
85 elif err.errno == errno.EACCES:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
想請問老師安裝了chromedriver, 放在和文件同一個資料夾了,還是出現 WebDriverException: Message: 'chromedriver' executable needs to be in PATH,請問可能是甚麼原因呢?我查過網路了還是無法解決問題
回答列表
-
2020/07/14 下午 11:35張維元 (WeiYuan)贊同數:0不贊同數:0留言數:2
嗨,因為你放錯了。你可以截圖一下,.ipynb 跟 chromedriver 所在的資料夾嗎?可以幫你確認一下!