0

现在我正在用 python 开发一个中型项目。

它有许多模块,其中一些是自定义模块。其中一些是非python文件(可能是配置文件),需要使用例如复制/粘贴(例如当客户端运行这个应用程序并插入一些硬件设备时,应用程序将配置硬件设备并复制一些应用程序文件到硬件设备(可能是 ROM))

首先我的问题是:我可以用我的所有代码、模块和非 python 文件创建 1 个单个 exe 吗?

如果是,我该怎么办?

4

2 回答 2

1

您可以尝试更改方法并将模块中的所有文件作为文本放入。然后您可以使用 py2exe 创建可执行文件,它将包含您需要的所有数据。仅当您有一些小文件时,这种方法才有意义。

如果您想嵌入更多更大的文件,请查看该解决方案: Py2exe: Embed static files in exe file itself and access them

于 2013-10-22T11:21:05.450 回答
0
  1. 打开 CMD
  2. 更改 PyInstaller 目录的路径。(ex-C:\PyInstaller-2.1)
  3. 使用这个命令

    pyinstaller.py my.py --noconsole --onefile --icon=icon.ico

将 my.py 更改为您的脚本名称。

--noconsole option remove the python console while executing your program. If you need console to get an output,just remove --noconsole
--onefile option makes all the modules and files in to one executable file.
--icon=icon.ico gives your exe an icon.Remember to put your icon file in Pyinstaller directory
于 2015-01-07T09:04:03.023 回答