<i id='H1hBi'><tr id='H1hBi'><dt id='H1hBi'><q id='H1hBi'><span id='H1hBi'><b id='H1hBi'><form id='H1hBi'><ins id='H1hBi'></ins><ul id='H1hBi'></ul><sub id='H1hBi'></sub></form><legend id='H1hBi'></legend><bdo id='H1hBi'><pre id='H1hBi'><center id='H1hBi'></center></pre></bdo></b><th id='H1hBi'></th></span></q></dt></tr></i><div id='H1hBi'><tfoot id='H1hBi'></tfoot><dl id='H1hBi'><fieldset id='H1hBi'></fieldset></dl></div>
    1. <legend id='H1hBi'><style id='H1hBi'><dir id='H1hBi'><q id='H1hBi'></q></dir></style></legend>

      <small id='H1hBi'></small><noframes id='H1hBi'>

          <bdo id='H1hBi'></bdo><ul id='H1hBi'></ul>
        <tfoot id='H1hBi'></tfoot>

        如何在 pyinstaller 中包含 chromedriver?

        时间:2023-06-06

        <tfoot id='wwPOx'></tfoot>
          <tbody id='wwPOx'></tbody>
              <bdo id='wwPOx'></bdo><ul id='wwPOx'></ul>

              1. <legend id='wwPOx'><style id='wwPOx'><dir id='wwPOx'><q id='wwPOx'></q></dir></style></legend>
                <i id='wwPOx'><tr id='wwPOx'><dt id='wwPOx'><q id='wwPOx'><span id='wwPOx'><b id='wwPOx'><form id='wwPOx'><ins id='wwPOx'></ins><ul id='wwPOx'></ul><sub id='wwPOx'></sub></form><legend id='wwPOx'></legend><bdo id='wwPOx'><pre id='wwPOx'><center id='wwPOx'></center></pre></bdo></b><th id='wwPOx'></th></span></q></dt></tr></i><div id='wwPOx'><tfoot id='wwPOx'></tfoot><dl id='wwPOx'><fieldset id='wwPOx'></fieldset></dl></div>

                <small id='wwPOx'></small><noframes id='wwPOx'>

                • 本文介绍了如何在 pyinstaller 中包含 chromedriver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 pyinstaller 创建我的 python 脚本的可执行文件.
                  在脚本中我使用了这些导入:

                  I am using pyinstaller to create an executable of my python script.
                  In the script I'm using these imports:

                  from selenium import webdriver
                  from selenium.webdriver.chrome.options import Options
                  etc...
                  

                  问题是,当运行 pyinstaller myscript.py 时,会导致包含 Firefox,而不是 Chrome.结果文件夹 c:...distmyscriptseleniumwebdriver 有一个 firefox 文件夹,所以它只是跳过了 chromedriver,这对我来说是一个严重的问题,因为脚本需要与 Chrome 一起运行.
                  围绕这个主题只有几个问题,但没有解决问题的答案.
                  我正在考虑将 --hidden-import MODULENAME 标签添加到命令中,但 chromedriver.exe 不是模块...谢谢

                  The problem is, when running pyinstaller myscript.py , it will result in including Firefox, instead of Chrome. In the result folder c:...distmyscriptseleniumwebdriver there is a firefox folder, so it is simply skipping chromedriver, and it is a serious problem for me, because the script needs to run with Chrome.
                  There is only a few questions around this topic, but there is no answer to solve the issue.
                  I was thinking on adding the --hidden-import MODULENAME tag to the command, but chromedriver.exe is not a module... Thanks

                  推荐答案

                  应该添加为二进制文件,因为是二进制文件...
                  因此,需要一个自定义规范文件,其中应该定义本地系统上 chromedriver 的路径以及相对于 distmyscript 的所需位置,因此它看起来像这样:

                  It should be added as a binary file, since it is a binary file...
                  So a custom spec file needed where the chromedriver's path on the local system and the desired location relative to the distmyscript should be defined, so it looks something like this:

                  .....
                  a = Analysis(['myscript.py'],
                               pathex=['path\to\my\script'],
                               binaries=[ ('path\to\my\chromedriver.exe', '.\selenium\webdriver') ],
                               datas=None,
                  ....
                  

                  然后使用这个规范文件运行 pyinstaller:pyinstaller myscript.spec myscript.py

                  And then run the pyinstaller with this spec file: pyinstaller myscript.spec myscript.py

                  这篇关于如何在 pyinstaller 中包含 chromedriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Windows 10 上安装 ChromeDriver 并使用 Chrome 运行 Selenium 测试? 下一篇:如何修复“无效的参数:无效的‘到期’"在向 chromedriver 添加 cookie 时在 Seleniu

                  相关文章

                  1. <tfoot id='CqwTK'></tfoot>

                        <bdo id='CqwTK'></bdo><ul id='CqwTK'></ul>

                      <small id='CqwTK'></small><noframes id='CqwTK'>

                      <legend id='CqwTK'><style id='CqwTK'><dir id='CqwTK'><q id='CqwTK'></q></dir></style></legend>
                    1. <i id='CqwTK'><tr id='CqwTK'><dt id='CqwTK'><q id='CqwTK'><span id='CqwTK'><b id='CqwTK'><form id='CqwTK'><ins id='CqwTK'></ins><ul id='CqwTK'></ul><sub id='CqwTK'></sub></form><legend id='CqwTK'></legend><bdo id='CqwTK'><pre id='CqwTK'><center id='CqwTK'></center></pre></bdo></b><th id='CqwTK'></th></span></q></dt></tr></i><div id='CqwTK'><tfoot id='CqwTK'></tfoot><dl id='CqwTK'><fieldset id='CqwTK'></fieldset></dl></div>