1

As noted in the answer to my question here, setting the path to chromedriver in binaries in the Pyinstaller spec file (binaries=[('/usr/bin/chromedriver', './selenium/webdriver')]) didn’t have an effect (unless it was set incorrectly). That is, chromedriver is accessed as long as it’s in the PATH (/usr/bin in this case). My question regards the possibility to bundle chromedriver in the background so that it doesn’t have to be manually installed on another machine.

Community
  • 1
  • 1
ballade4op52
  • 2,142
  • 5
  • 27
  • 42

1 Answers1

3

I succesfully bundled chromedriver with pyinstaller (although unfortunately, my virusscanner flagged it, after I ran the exe, but that's another problem)

I guess your problem is that you do not give the correct path to the webdriver in the script (using keyword executable_path). Also, I included the chromedriver as a data-file, although I'm not sure if that makes a difference..

Here is my example.

sel_ex.py:

from selenium import webdriver

import os, sys, inspect     # http://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path
current_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe() ))[0]))

def init_driver():
    chromedriver = os.path.join(current_folder,"chromedriver.exe")
    # via this way, you explicitly let Chrome know where to find 
    # the webdriver.
    driver = webdriver.Chrome(executable_path = chromedriver) 
    return driver

if __name__ == "__main__":
    driver = init_driver()
    driver.get("http://www.imdb.com/")

sel_ex.spec:

....
binaries=[],
datas=[("chromedriver.exe",".")],
....

In this way, the chromedriver was stored in the main folder, although it should not matter where it is stored, as long as the script correct path through the keyword executable_path

disclaimers: -I did not use the one-file-settings, but that shouldn't make a difference. -my OS is windows

arrethra
  • 99
  • 5
  • Just to clarify and consolidate relevant posts, I believe this problem was solved in a post I formatted differently here: http://stackoverflow.com/questions/41009492/pyinstaller-generated-app-does-not-link-to-the-specified-binary-chromedriver. The last comment I made to the person who posted the answer specifies why. – ballade4op52 Mar 28 '17 at 20:23
  • So yes, the path was the reason – ballade4op52 Mar 28 '17 at 20:24