Pyinstaller 生成的应用程序未链接到指定的二进制文件(chromedriver) [英] Pyinstaller generated app does not link to the specified binary (chromedriver)

查看:57
本文介绍了Pyinstaller 生成的应用程序未链接到指定的二进制文件(chromedriver)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照此处答案中的建议更新 Pyinstaller 规范文件后 (How to include chromedriver使用 pyinstaller?),仍然无法从生成的应用程序文件访问 chromedriver.问题可能出在 .\\selenium\\webdriver 上吗?这是从答案中复制的,我不确定它是否特定于 Windows 操作系统.

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.

在终端中运行 UNIX 可执行文件,访问 chromedriver.

Running the UNIX executable in terminal works, accessing chromedriver.

完整的规范文件是:

# -*- 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)

在终端中使用 pyinstaller appname.spec scriptname.py --windowed --onefile 行来生成应用程序.

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

推荐答案

是的,那是 Windows 路径.在 Unix 中,请改用 ./selenium/webdriver.它告诉在包中放置 chromedriver 二进制文件的位置,因此在 pyinstall 之后,chromedriver 将位于 /path/to/bundle/dist/selenium/webdriver.
然后在代码中你应该使用这样的东西来访问它(这是一个远程示例):

Yes, that was Windows path. In Unix, 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) ... 

这篇关于Pyinstaller 生成的应用程序未链接到指定的二进制文件(chromedriver)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆