Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何修复错误消息:';chromedriver.exe';可执行文件可能有错误的权限_Python_Selenium_Selenium Webdriver_Selenium Chromedriver_Google Colaboratory - Fatal编程技术网

Python 如何修复错误消息:';chromedriver.exe';可执行文件可能有错误的权限

Python 如何修复错误消息:';chromedriver.exe';可执行文件可能有错误的权限,python,selenium,selenium-webdriver,selenium-chromedriver,google-colaboratory,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,Google Colaboratory,我正在安装selenium的webdriver。但是,我得到了以下错误: PermissionError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self) 75

我正在安装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
PermissionError回溯(最近一次调用)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py
开始时(自我)
75 stderr=self.log_文件,
--->76标准偏差=管道)
77除类型错误外:
/usr/lib/python3.6/subprocess.py在uuuu init_uuuu中(self、args、bufsize、,
可执行文件、stdin、stdout、stderr、preexec_fn、close_fds、shell、cwd、env、,
通用\新行、startupinfo、creationflags、还原\信号、启动\新\会话、通过\ fds、编码、错误)
708错误读取,错误写入,
-->709恢复信号,启动新会话)
710除:
/usr/lib/python3.6/subprocess.py in_execute_child(self、args、execute、preexec_fn、close_fds、pass_fds、cwd、env、startupinfo、creationflags、shell、p2cread、p2cwrite、c2pwrite、errread、errwrite、restore_信号、start_new_会话)
1343 err_msg+=':'+repr(err_文件名)
->1344引发子项异常类型(errno\u num、err\u msg、err\u filename)
1345引发子项异常类型(错误消息)
PermissionError:[Errno 13]权限被拒绝:'/usr/bin/chromedriver.exe'
在处理上述异常期间,发生了另一个异常:
WebDriverException回溯(最近一次调用上次)
在()
1从selenium导入webdriver
---->2 driver=webdriver.Chrome(可执行文件路径=“/usr/bin/chromedriver.exe”)
3.获取(“http://www.google.com")
4.显示停止()
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py in_uuuuuuinit_uuuuu(self、可执行_u路径、端口、选项、服务参数、所需_u功能、服务_u日志_u路径、chrome_u选项、保持_u活动)
71服务参数=服务参数,
72日志路径=服务日志路径)
--->73自助服务启动()
74
75尝试:
/启动时的usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py(self)
86提高WebDriverException(
87“'%s'可执行文件可能有错误的权限。%s”%(
--->88 os.path.basename(self.path)、self.start\u错误消息)
89                 )
90其他:
WebDriverException:消息:“chromedriver.exe”可执行文件可能具有错误的权限。请看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则有不同的格式。如果您不想通过PackageManager安装,只需从站点下载chromedriver即可。


如果仍然出现错误,请转到
/usr/bin
目录,您需要运行类似
chmod a+x chromedriver
的程序来将其标记为可执行。

实际上不需要这个!如果不起作用,为什么要在“/bin/”目录下添加二进制文件?朋友以不同的方式设置驱动程序,系统范围的安装是为了防止此类模块冲突。为此,使用了
APT
PIP
无法满足足够的要求(Chromium是一个主要的系统组件,与Python没有关系)。感谢您的帮助。我已经执行了
chmod a+x chromedriver.exe
。但是,我遇到另一个错误
OSError:[Errno 8]Exec格式错误:'/usr/bin/chromedriver.exe'
更新了答案。请查收