ballade4op52
ballade4op52

Reputation: 2267

Pyinstaller generated app does not link to the specified binary (chromedriver)

After updating the Pyinstaller spec file as suggested in the answer here (How to include chromedriver with pyinstaller?), chromedriver is still not being accessed from the generated app file. Could the issue be with .\\selenium\\webdriver? That was copied from the answer and I'm not sure it's specific to a Windows OS.

Running the UNIX executable in terminal works, accessing chromedriver.

The full spec file is:

# -*- mode: python -*-

block_cipher = None


a = Analysis([‘scriptname.py'],
             pathex=['/Users/Name/Desktop'],
             binaries=[('/usr/local/bin/chromedriver', '.\\selenium\\webdriver')],
             datas=None,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name=‘app name’,
          debug=False,
          strip=False,
          upx=True,
          console=False )
app = BUNDLE(exe,
             name=‘appname.app',
             icon=None,
             bundle_identifier=None)

The line pyinstaller appname.spec scriptname.py --windowed --onefile is used in terminal to generate the app.

Upvotes: 3

Views: 3729

Answers (1)

monami
monami

Reputation: 614

Yes, that was Windows path. In Unix, you need to use ./selenium/webdriver instead. It tells where to place the chromedriver binary in the bundle, so after pyinstall, chromedriver will be in /path/to/bundle/dist/selenium/webdriver.
Then in the code you should use something like this to reach it (it's a remote example):

dir = os.path.dirname(__file__)
chrome_path = os.path.join(dir, 'selenium','webdriver','chromedriver.exe')
service = service.Service(chrome_path) ... 

Upvotes: 2

Related Questions