0

I'm new at Python and I'm trying to use selenium webdriver to do web scraping from a webpage. When I run my code, I have not problems in obtaining the results I need, but when someone else tries to run the code from an executable it shows the error: selenium.common.exceptions.webdriverexception: message: 'chromedriver.exe' unexpectedly exited.status code was: 1. The path where I'm saving chromedriver.exe is a public repository. Can someone help me with this please? Here is the piece of code I'm using:

from selenium import webdriver

url= "https://www.byma.com.ar/obligaciones-negociables/"
    
driver = webdriver.Chrome(executable_path=r'\\path\\chromedriver.exe')

driver.implicitly_wait(30)
    
driver.get(url)
    
time.sleep(2)
cruisepandey
  • 28,520
  • 6
  • 20
  • 38

1 Answers1

3

You do not need to setup a driver like this :

driver = webdriver.Chrome(executable_path=r'\\path\\chromedriver.exe')

do this :

This is a pre - requisite

Installation

pip install chromedriver-autoinstaller

Usage:

Just type import chromedriver_autoinstaller in the module you want to use chromedriver.

Example

from selenium import webdriver
import chromedriver_autoinstaller


chromedriver_autoinstaller.install()  # Check if the current version of chromedriver exists
                                      # and if it doesn't exist, download it automatically,
                                      # then add chromedriver to path

driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title

and the export this changes to your executables

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • Thanks for the answer. The problem here ,that I forget to mention, is that the users of the executable can´t download the executable to their pc's. So, is there any way to include de chromedriver.exe in a folder of the 'dist' folder created when running the project to an .exe with pyinstaller? – Agustin Balestra Jun 18 '21 at 18:57
  • You don't need chromedriver.exe at all with the above solution – cruisepandey Jun 18 '21 at 18:59
  • Ok, I think I've already understand your point. Thanks for your help! – Agustin Balestra Jun 18 '21 at 19:02