【问题标题】:How do I give permission to chromedriver.exe?如何授予 chromedriver.exe 权限?
【发布时间】:2021-04-12 15:27:13
【问题描述】:

我在人脸识别项目中使用 chrome 驱动,但在下面的第 4 行出现错误。 如何授予 chromedriver.exe 权限?

代码:

data_path = '/content/drive/MyDrive/FaceRecognition/faces' 
onlyfiles = [f for f in listdir(data_path) if isfile(join(data_path,f))]
url='https://www.naver.com/' 
browser = webdriver.Chrome(r'/content/drive/MyDrive/FaceRecognition/chromedriver/chromedriver.exe')

================================================ ================================================== ===== 错误信息:

PermissionError                           Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)
     75                                             stderr=self.log_file,
---> 76                                             stdin=PIPE)
     77         except TypeError:

4 frames
PermissionError: [Errno 13] Permission denied: '/content/drive/MyDrive/FaceRecognition/chromedriver/chromedriver.exe'

During handling of the above exception, another exception occurred:

WebDriverException                        Traceback (most recent call last)
/usr/local/lib/python3.7/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

【问题讨论】:

  • 你真的在 Unix 系统上使用 chromedriver.EXE 吗?

标签: python selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

此错误消息...

PermissionError: [Errno 13] Permission denied: '/content/'
.
WebDriverException: Message: '' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

...表示未检测到 WebDriver 可执行文件,因此Selenium 怀疑可执行文件可能具有错误的权限。


解决方案

在传递 Key executable_path 时,您需要传递 WebDriver 变体名称的绝对路径 ,即chromedriver如下:

driver = webdriver.Chrome(executable_path='/content/chromedriver')
                          webdriver variant name ^^^chromedriver^^^ needs to be appended

参考

您可以在以下位置找到一些相关讨论:

【讨论】:

  • 如果我错了,请纠正我,但您不在 Unix 系统上使用 chromedriver.EXE,对吧?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-22
  • 2016-08-24
  • 2015-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多