Pyinstaller生成的文件不存在。\n

2024-04-20 08:31:40 发布

您现在位置:Python中文网/ 问答频道 /正文

在windows 10 bash shell中对python代码文件使用此命令时:

 pyinstaller Test.py

它生成这些文件(以及其他一些文件):

enter image description here

我不确定是否生成的文件是一个.exe文件,将工作。我跑不了。你能帮忙吗?谢谢。你知道吗


Tags: 文件代码pytest命令bashwindowsshell
1条回答
网友
1楼 · 发布于 2024-04-20 08:31:40

在我看到的屏幕截图中,您尝试在Linux操作系统上运行pyinstaller,因为生成的*.so文件是Linux指定的共享对象。此外,Test文件是Linux指定的可执行文件,没有扩展名。你知道吗

如果要从Python文件/项目创建EXE文件,则必须在Windows操作系统上运行pyintallerpyinstaller将收集所有需要的文件,例如:dll、sdk等。。。你知道吗

我从PyInstaller官方文档中复制了以下部分:

PyInstaller is tested against Windows, Mac OS X, and Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a Linux app you run it in Linux, etc. PyInstaller has been used successfully with AIX, Solaris, and FreeBSD, but is not tested against them.

一些提示说明如何从Python文件/项目创建一个工作EXE文件。你知道吗

使用 onefile-F标志:

“在一个文件模式下,没有要收集的调用,EXE实例接收所有脚本、模块和二进制文件。”例如:pyinstaller onefile test.py

使用 windowed-w标志:

Windows和MacOSX:不为标准i/o提供控制台窗口。在MacOSX上,这也会触发构建OSX.app包。在*NIX系统中忽略此选项。你知道吗

使用 clean标志:

在构建之前清理PyInstaller缓存并删除临时文件。你知道吗

我推荐的命令:

pyinstaller -Fw  clean test.py

您应该在Windows操作系统上运行上述命令。你知道吗

仅供参考:

如果您有一个复杂的Python项目,并且您有依赖项(必需的文件、文件夹结构等),我建议您使用*.spec文件。您可以在以下链接上阅读有关它的详细信息:https://pythonhosted.org/PyInstaller/spec-files.html

相关问题 更多 >