Python - 构建可执行文件时遇到问题 [英] Python - Trouble in building executable

查看:24
本文介绍了Python - 构建可执行文件时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名 Python 程序员,我正在尝试构建一个可执行的二进制文件来将我的软件分发给我的客户,即使它不是完全可执行的我希望能够以一种方便的方式分发我的软件为最终用户.

I'm a python programmer and I'm trying to build an executable binary to distribute my software to my clients, even if it's not fully executable I want to be able to distribute my software in a way so that it is convenient for the end user.

我已经尝试过 PyInstaller 和 Py2Exe,但我在使用特定软件时遇到了同样的问题.

I have already tried PyInstaller as well as Py2Exe and I'm facing the same problem with a particular software.

我在我的程序中使用了 splinter 模块(这当然是一个新的高级框架,可以与 Selenium 等其他框架进行交互),每次我尝试编译它时,似乎都有一个名为webdriver.xpi"的文件始终被排除在最终包之外,因此当程序尝试执行 web 驱动程序时,它会失败并显示 IO 错误,指出未找到文件webdriver.xpi"....但除了 GUI 和所有内容工作得很好.

I used the splinter module for my program (which of course is a new high level framework to interact with other frameworks like Selenium) and every time I try to compile it there seems to be a file called "webdriver.xpi" that is always left out from the final package and therefore when the program attempts to execute the web-driver it fails with an IO Error saying that the file "webdriver.xpi" was not found....but other than that the GUI and everything works perfectly fine.

那么有没有办法手动包含它?我尝试通过浏览到特定文件夹 @ library.zip 文件来手动包含它,但没有奏效.

So is there a way to include it even manually? I tried including it manually by browsing to the specific folder @ library.zip file but it didn't work.

我不是这方面的专家,我依赖 GUI2Exe 来构建所有东西……如果可能的话,我真的很感激一些关于如何解决这个问题的建议.

I'm not really expert in this matter and I rely on GUI2Exe for building everything...and I would really appreciate some advice if possible on how to fix this.

谢谢.

推荐答案

我整天都在处理这个问题,并找到了一个解决方法,虽然偷偷摸摸,但确实有效.在我收到的错误消息中,我注意到库 .zip 之间有一个空格.我无法在 py2exe 或 selenium 的源代码中找到它.我也曾尝试将 xpi 文件放在库 zip 中,但没有奏效.解决方法是:

I was at this all day and found a workaround, it's sneaky but it works. In the error message I was receiving I noticed that there was a space between in library .zip. I could not trace it down in the source code for py2exe or selenium. I too had tried putting the xpi file in the library zip and it did not work. The workaround is:

  1. 在您的安装文件中使用以下选项:

  1. In your setup file use these options:

setup(
    console=['yourFile.py'],
    options={
            "py2exe":{
                    "skip_archive": True,
                    "unbuffered": True,
                    "optimize": 2
            }
    }
)

  • 运行py2exe安装

  • Run the py2exe install

    应该可以.

    这篇关于Python - 构建可执行文件时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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