Python “Webdrivers”可执行文件可能具有错误的权限。请参阅 https://sites.google.com/a/chromium.org/chromedriver/home
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47148872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
提问by Ash1x
I've looked around checked both documentations and have found no answer.
我环顾四周检查了两个文档,但没有找到答案。
I've been trying to use InstaPy a instagram api for python. After failing with multiple errors and assuming InstaPy is just having some issues so i tried to raw code it using selinium. after inserting the example code and alter it to my liking i just made sure this one would work. I received a new error instead of the old one saying the permissions may not be right. I have tried reinstall and running as admin but nothing works. how do i fix this and/or what does this mean
我一直在尝试将 InstaPy 用作 Python 的 Instagram api。在因多个错误而失败并假设 InstaPy 只是遇到一些问题后,我尝试使用 selinium 对其进行原始编码。插入示例代码并根据我的喜好对其进行更改后,我只是确保此代码可以工作。我收到一个新错误而不是旧错误,说权限可能不正确。我试过重新安装并以管理员身份运行,但没有任何效果。我该如何解决这个问题和/或这是什么意思
Code:
代码:
import time
from selenium import webdriver
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
Error:
错误:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Webdrivers\RawBot.py", line 5, in <module>
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
回答by DebanjanB
This error message...
这个错误信息...
WebDriverException: Message: 'Webdrivers' executable may have wrong permissions.
...implies that the ChromeDrivervariant you are trying to use have wrong permissions.
...暗示您尝试使用的ChromeDriver变体具有错误的权限。
You seem to have tried out:
你似乎已经尝试过:
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search system $PATH variable.
A few words:
几句话:
If your underlying osis windows:
- You have to download chromedriver_win32.zipfrom the ChromeDriver Download Locationand unzip it for usage.
- Additionally, if you are explicitly specifying the Chromedriverbinary path you have to append the binary extension as well, effectively i.e. chromedriver.exe.
- While mentioning the Chromedriverbinary path you have to either use the single forward slashi.e.
(/)
along with the raw(r)
switch or you have to use the escaped backslashi.e.(\\)
. So your effective line of code will be :
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
If your underlying osis linux:
- You have to download chromedriver_linux64from the ChromeDriver Download Locationand untar it for usage.
- Additionally, if you are explicitly specifying the Chromedriverbinary path you don'thave to provide any extension for the executable binary, effectively i.e. chromedriver.
- While mentioning the Chromedriverbinary path you have to use the single forward slashi.e.
(/)
. So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
If your underlying osis macos:
- You have to download chromedriver_mac64from the ChromeDriver Download Locationand untar it for usage.
- Additionally, if you are explicitly specifying the Chromedriverbinary path you don'thave to provide any extension for the executable binary, effectively i.e. chromedriver.
- While mentioning the
chromedriver
binary path you have to use the single forward slashi.e.(/)
. So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
- 您必须从ChromeDriver 下载位置下载chromedriver_win32.zip并解压缩以供使用。
- 此外,如果您明确指定Chromedriver二进制路径,则还必须附加二进制扩展名,即chromedriver.exe。
- 在提到Chromedriver二进制路径时,您必须使用单个正斜杠ie
(/)
以及原始(r)
开关,或者您必须使用转义的反斜杠ie(\\)
。 所以你的有效代码行将是:
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
- 您必须从ChromeDriver 下载位置下载chromedriver_linux64并将其解压缩以供使用。
- 此外,如果您明确指定Chromedriver二进制路径,则不必为可执行二进制文件提供任何扩展名,即chromedriver。
- 在提到Chromedriver二进制路径时,您必须使用单个正斜杠ie
(/)
。 所以你的有效代码行将是:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
- 您必须从ChromeDriver 下载位置下载chromedriver_mac64并将其解压缩以供使用。
- 此外,如果您明确指定Chromedriver二进制路径,则不必为可执行二进制文件提供任何扩展名,即chromedriver。
- 在提到
chromedriver
二进制路径时,您必须使用单个正斜杠即(/)
. 所以你的有效代码行将是:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
回答by Ramana
This got solved when you enter the full file name which is "chromedriver.exe". Try this if you are on windows
当您输入完整的文件名“chromedriver.exe”时,这个问题就解决了。如果你在 Windows 上试试这个
回答by BootstrapYou
had same issue in django.
在 Django 中有同样的问题。
However when I ran the same code locally (not activating my django app) it was fine and didn't have to explicitly define the path to the chrome driver.
但是,当我在本地运行相同的代码(不激活我的 django 应用程序)时,它很好,不必明确定义 chrome 驱动程序的路径。
Got around it by explicitly defining the path and the chromederiver.exe
通过明确定义路径和 chromederiver.exe 来解决它
similar to the answer above. path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
类似于上面的答案。path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
in my case, since I want to eventually post my app I used dynamic paths
就我而言,因为我想最终发布我的应用程序,所以我使用了动态路径
ie.
IE。
import os
BASE_oaAPP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_oaAPP_Utilities_DIR = os.path.join(BASE_oaAPP_DIR, 'mySubFolderInTheApp')
def utilsPathFileName(fileName):
return os.path.join(BASE_oaAPP_Utilities_DIR, fileName)
chrome_path = utilsPathFileName('chromedriver.exe')
driver = webdriver.Chrome(chrome_path)
回答by Urban P.
You just have to add
你只需要添加
/chromedriver.exe
/chromedriver.exe
at the end of the path like this:
在路径的尽头是这样的:
driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')
driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')
Note: If you copy the path from "File Explorer" you will get:
注意:如果您从“文件资源管理器”复制路径,您将获得:
C:\Users\User\Downloads\chromedriver_win32
C:\用户\用户\下载\chromedriver_win32
You will need to use double backslashes like this:
您需要像这样使用双反斜杠:
C:\\Users\\User\\Downloads\\chromedriver_win32
C:\\用户\\用户\\下载\\chromedriver_win32
so you don't get a syntax error. Or you can just use forward slashes.
所以你不会收到语法错误。或者你可以只使用正斜杠。
回答by venkatadileep
I got the same error when wrongly installed drives(when for mac was downloaded windows drivers) once I correct it worked fine
一旦我纠正它工作正常,当错误安装驱动器时(当为 Mac 下载 Windows 驱动程序时)我遇到了同样的错误
回答by Balaji
You need to add exe at the end of the path of driver and it works.
您需要在驱动程序路径的末尾添加exe,它才能工作。
回答by gutt23
locate your installed driver.exe, shift+right click, copy as path, paste it to your IDE
找到您安装的 driver.exe,shift+右键单击,复制为路径,将其粘贴到您的 IDE
回答by Yuvraj Singh
if you are using chrome you must specify the full path of the chromedriver. search for the directory in which your chromedriver executable file resides. click shift+right click on the executable file. select "copy as path" and paste it in your script. don't forget to use a double backslash
如果您使用的是 chrome,则必须指定 chromedriver 的完整路径。搜索 chromedriver 可执行文件所在的目录。单击shift+右键单击可执行文件。选择“复制为路径”并将其粘贴到您的脚本中。不要忘记使用双反斜杠
so it should be:
所以应该是:
driver = webdriver.Chrome('C:\Utility\BrowserDrivers\chromedriver.exe')
回答by Gregor
For me, none of the answers above worked. But moving the chromedriver.exe to a new path (desktop in my case) solved it.
对我来说,上面的答案都没有奏效。但是将 chromedriver.exe 移动到新路径(在我的情况下为桌面)解决了它。
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
回答by josuedjh
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件可能具有错误的权限。请参阅https://sites.google.com/a/chromium.org/chromedriver/home