如何修复错误消息:'chromedriver.exe' 可执行文件可能具有错误的权限
How to fix error Message: 'chromedriver.exe' executable may have wrong permissions
我正在安装 selenium 的 webdriver。但是我收到以下错误:
PermissionError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py
in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
/usr/lib/python3.6/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)
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
/usr/lib/python3.6/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)
1343 err_msg += ': ' + repr(err_filename)
-> 1344 raise child_exception_type(errno_num, err_msg, err_filename)
1345 raise child_exception_type(err_msg)
PermissionError: [Errno 13] Permission denied: '/usr/bin/chromedriver.exe'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
<ipython-input-50-92acfe45475a> in <module>()
1 from selenium import webdriver
----> 2 driver = webdriver.Chrome(executable_path="/usr/bin/chromedriver.exe")
3 driver.get("http://www.google.com")
4 display.stop()
/usr/local/lib/python3.6/dist-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:
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
86 raise WebDriverException(
87 "'%s' executable may have wrong permissions. %s" % (
---> 88 os.path.basename(self.path), self.start_error_message)
89 )
90 else:
WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
我已下载 chromedriver.exe
并将其添加到 /usr/bin
,代码行如下:!sudo mv /usr/local/bin/chromedriver.exe /usr/bin
你不能解决我代码的错误吗?
提前致谢!
可能是因为平台和 chromedriver 格式不匹配。例如 windows 需要 chromedriver.exe,而 linux 和 mac 有不同的格式。如果您不想通过包管理器安装,只需从站点下载 chromedriver。
https://sites.google.com/a/chromium.org/chromedriver/downloads
如果仍然出现错误,则转到 /usr/bin
目录,您需要 运行 类似 chmod a+x chromedriver
的内容来将其标记为可执行文件。
我正在安装 selenium 的 webdriver。但是我收到以下错误:
PermissionError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py
in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
/usr/lib/python3.6/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)
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
/usr/lib/python3.6/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)
1343 err_msg += ': ' + repr(err_filename)
-> 1344 raise child_exception_type(errno_num, err_msg, err_filename)
1345 raise child_exception_type(err_msg)
PermissionError: [Errno 13] Permission denied: '/usr/bin/chromedriver.exe'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
<ipython-input-50-92acfe45475a> in <module>()
1 from selenium import webdriver
----> 2 driver = webdriver.Chrome(executable_path="/usr/bin/chromedriver.exe")
3 driver.get("http://www.google.com")
4 display.stop()
/usr/local/lib/python3.6/dist-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:
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
86 raise WebDriverException(
87 "'%s' executable may have wrong permissions. %s" % (
---> 88 os.path.basename(self.path), self.start_error_message)
89 )
90 else:
WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
我已下载 chromedriver.exe
并将其添加到 /usr/bin
,代码行如下:!sudo mv /usr/local/bin/chromedriver.exe /usr/bin
你不能解决我代码的错误吗? 提前致谢!
可能是因为平台和 chromedriver 格式不匹配。例如 windows 需要 chromedriver.exe,而 linux 和 mac 有不同的格式。如果您不想通过包管理器安装,只需从站点下载 chromedriver。 https://sites.google.com/a/chromium.org/chromedriver/downloads
如果仍然出现错误,则转到 /usr/bin
目录,您需要 运行 类似 chmod a+x chromedriver
的内容来将其标记为可执行文件。