Reputation: 77
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')
This is the error
---------------------------------------------------------------------------
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
Upvotes: 3
Views: 7585
Reputation: 193108
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.
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.
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')
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')
You can find a couple of detailed relevant discussions in:
Upvotes: 2
Reputation: 40828
I made a library to help using selenium in Colab easier.
You can just call this
!pip install kora -q
from kora.selenium import wd
wd.get(url)
Upvotes: 0