I wrote a function for scraping data from a website in a Jupyter Notebook. The function works perfectly fine when running in that notebook and when I use ipynb
to import the functions from that notebook it imports them successfully. Then when I run the function in the second notebook I get: WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
. The weirdest part is that this works fine on my MacBook but not on my PC. Has anyone encountered this and found a solution?
The import I use is: from ipynb.fs.full.my_notebook import my_function
. I then create a dataframe using df = my_function(x, y, z)
, which is where I get the error.
CodePudding user response:
It's possible to set the path to chromedriver
executable instead of using the one in the PATH
.
from selenium.webdriver.chrome.service import Service
service = Service(executable_path='/Users/<user_name>/Downloads/chromedriver')
...