简体   繁体   English

Pyinstallar 不创建.exe 文件

[英]Pyinstallar doesn't create .exe file

I'm trying to create an executable file for a simple 'Hello World' python code.我正在尝试为简单的“Hello World”python 代码创建一个可执行文件。 I'm using an Ubuntu Subsystem in Windows 11 and I'm trying to create the.exe file with the command:我在 Windows 11 中使用 Ubuntu 子系统,我正在尝试使用以下命令创建 .exe 文件:

pyinstaller --onefile Test.py

The command runs and creates folders "build" and "dist", but it doesn't create the.exe file inside the "dist" folder as it should do.该命令运行并创建文件夹“build”和“dist”,但它没有像它应该做的那样在“dist”文件夹内创建 .exe 文件。

In the terminal I have the fallowing message:在终端中,我有以下消息:

mbseidel@Matheus-Seidel:/mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up$ pyinstaller --onefile Test.py
156 INFO: PyInstaller: 5.7.0
156 INFO: Python: 3.8.10
166 INFO: Platform: Linux-4.4.0-25272-Microsoft-x86_64-with-glibc2.29
173 INFO: wrote /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/Test.spec
181 INFO: UPX is not available.
183 INFO: Extending PYTHONPATH with paths
['/mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up']
648 INFO: checking Analysis
648 INFO: Building Analysis because Analysis-00.toc is non existent
648 INFO: Initializing module dependency graph...
651 INFO: Caching module graph hooks...
656 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
662 INFO: Analyzing base_library.zip ...
1652 INFO: Loading module hook 'hook-heapq.py' from '/home/mbseidel/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
1802 INFO: Loading module hook 'hook-encodings.py' from '/home/mbseidel/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
2734 INFO: Loading module hook 'hook-pickle.py' from '/home/mbseidel/.local/lib/python3.8/site-packages/PyInstaller/hooks'...
3599 INFO: Caching module dependency graph...
3695 INFO: running Analysis Analysis-00.toc
3808 INFO: Analyzing /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/Test.py
3812 INFO: Processing module hooks...
3823 INFO: Looking for ctypes DLLs
3827 INFO: Analyzing run-time hooks ...
3831 INFO: Looking for dynamic libraries
4781 INFO: Looking for eggs
4781 INFO: Python library not in binary dependencies. Doing additional searching...
4958 INFO: Using Python library /lib/x86_64-linux-gnu/libpython3.8.so.1.0
4979 INFO: Warnings written to /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/build/Test/warn-Test.txt
4995 INFO: Graph cross-reference written to /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/build/Test/xref-Test.html
5054 INFO: checking PYZ
5054 INFO: Building PYZ because PYZ-00.toc is non existent
5054 INFO: Building PYZ (ZlibArchive) /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/build/Test/PYZ-00.pyz
5204 INFO: Building PYZ (ZlibArchive) /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/build/Test/PYZ-00.pyz completed successfully.
5220 INFO: checking PKG
5221 INFO: Building PKG because PKG-00.toc is non existent
5221 INFO: Building PKG (CArchive) Test.pkg
7126 INFO: Building PKG (CArchive) Test.pkg completed successfully.
7132 INFO: Bootloader /home/mbseidel/.local/lib/python3.8/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run
7133 INFO: checking EXE
7133 INFO: Building EXE because EXE-00.toc is non existent
7133 INFO: Building EXE from EXE-00.toc
7134 INFO: Copying bootloader EXE to /mnt/c/Users/Matheus Seidel/OneDrive/NCEE Meus documentos/Arquivos padrão/Up/dist/Test
7138 INFO: Appending PKG archive to custom ELF section in EXE
7184 INFO: Building EXE from EXE-00.toc completed successfully.

It is weird because I tried the same thing a week ago and the.exe was created normally.这很奇怪,因为我一周前尝试了同样的事情,并且 .exe 是正常创建的。 I even tried unistalling and reinstalling the pyinstaller library, but still got the same results.我什至尝试卸载并重新安装 pyinstaller 库,但仍然得到相同的结果。

Since you're creating an executable under WSL, a Linux environment, your output executable would be that of a Linux binary instead of a Windows .exe file.由于您是在 WSL(Linux 环境)下创建可执行文件,因此您的 output 可执行文件将是 Linux 二进制文件而不是 Windows .exe文件。

Linux binary do not an extension, but they will still be properly run if you run the path to the binary file under your WSL shell (eg ./path_to_binary/binary_file ) Linux 二进制文件不是扩展名,但如果您在 WSL shell 下运行二进制文件的路径(例如./path_to_binary/binary_file ),它们仍然可以正常运行

If you wish to create an executable for Windows, the simplest way is to run the same code with pyinstaller on Windows itself rather than the WSL shell.如果您希望为 Windows 创建可执行文件,最简单的方法是在 Windows 本身而不是 WSL shell 上使用 pyinstaller 运行相同的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM