WebDriverException:消息:"chromedriver.exe"可执行文件可能通过Selenium Python使用Google合作实验室具有错误的权限 [英] WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions using Google Colaboratory through Selenium Python
问题描述
我正在使用Google Chrome版本83.0.4103.116和ChromeDriver 83.0.4103.39.我正在尝试在Google Colab中使用Chrome驱动程序.我将chromedriver的路径上传到Google colab后使用.你能指出我哪里出错了. 这是代码
I am using Google Chrome version 83.0.4103.116 and ChromeDriver 83.0.4103.39. I am trying to use chrome driver in google colab. I use the path of chromedriver after uploading it in google colab. Could you please point out where i m getting error. This is the code
import selenium
from selenium import webdriver
wd = webdriver.Chrome(r'/content/chromedriver.exe')
这是错误
---------------------------------------------------------------------------
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:
4 frames
PermissionError: [Errno 13] Permission denied: '/content/chromedriver.exe'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
/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
推荐答案
Google合作实验室
Colaboratory 是免费的Jupyter笔记本环境,需要无需设置,并且完全在云中运行,这使我们能够编写和执行代码,保存和共享您的分析以及访问强大的计算资源,而这一切都可以从您的浏览器免费获得.
Google Colaboratory
Colaboratory is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud which enables us to write and execute code, save and share your analyses, and access powerful computing resources, all for free from your browser.
整个合作实验室都在云VM中运行.如果调查VM,您会发现当前的colab笔记本正在Ubuntu 18.04.3 LTS之上运行.
The entire colab runs in a cloud VM. If you investigate the VM you will find that the current colab notebook is running on top of Ubuntu 18.04.3 LTS.
因此,在使用 Selenium 时,没有提及 WebDriver 变体对于扩展名,即.exe
,您需要删除扩展名.因此,有效的代码块将是:
So while using Selenium instead of mentioning the WebDriver variant along with the extension i.e. .exe
you need to drop the extension. So effectively your code block will be:
import selenium
from selenium import webdriver
wd = webdriver.Chrome('/content/chromedriver')
更新
如果您不确定 ChromeDriver a>正在下载,您可以将其移动到已知位置并按以下方式使用它:
Update
Incase you aren't sure where the ChromeDriver is getting downloaded you can move it to a known location and use it as follows:
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
from selenium import webdriver
wd = webdriver.Chrome('/usr/bin/chromedriver')
参考文献
您可以在以下位置找到一些详细的相关讨论:
References
You can find a couple of detailed relevant discussions in:
- "Webdrivers"可执行文件可能具有错误的权限.请参阅https://sites.google.com/a/chromium.org/chromedriver/home
- MAC上的硒,消息:"chromedriver"可执行文件可能具有错误的权限
- 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
- Selenium on MAC, Message: 'chromedriver' executable may have wrong permissions
这篇关于WebDriverException:消息:"chromedriver.exe"可执行文件可能通过Selenium Python使用Google合作实验室具有错误的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!