嘿,我试图将我的python代码转换为.exe
这样做的时候我正在使用 “ pyinstaller main.py-honefile”
它使用以下信息正确构建。
PS C:\Users\Kumbhak\PycharmProjects\pythonProject> pyinstaller main.py --onefile
209 INFO: PyInstaller: 6.5.0, contrib hooks: 2024.3
209 INFO: Python: 3.12.2
230 INFO: Platform: Windows-10-10.0.19045-SP0
230 INFO: wrote C:\Users\Kumbhak\PycharmProjects\pythonProject\main.spec
233 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Kumbhak\\PycharmProjects\\pythonProject']
423 INFO: checking Analysis
423 INFO: Building Analysis because Analysis-00.toc is non existent
424 INFO: Initializing module dependency graph...
425 INFO: Caching module graph hooks...
434 INFO: Analyzing base_library.zip ...
1218 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\
\pythonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
1903 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\\pyt
honProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
2512 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\\py
thonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
3359 INFO: Caching module dependency graph...
3427 INFO: Running Analysis Analysis-00.toc
3427 INFO: Looking for Python shared library...
3432 INFO: Using Python shared library: C:\Users\Kumbhak\AppData\Local\Programs\Python\Python
312\python312.dll
3432 INFO: Analyzing C:\Users\Kumbhak\PycharmProjects\pythonProject\main.py
3559 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\Kumbhak\\Pycha
rmProjects\\pythonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
3660 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\\pytho
nProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
4080 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\\
pythonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
5482 INFO: Loading module hook 'hook-nacl.py' from 'C:\\Users\\Kumbhak\\PycharmProjects\\pyth
onProject\\.venv\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
6113 INFO: Processing module hooks...
6143 INFO: Performing binary vs. data reclassification (3 entries)
6144 INFO: Looking for ctypes DLLs
6154 INFO: Analyzing run-time hooks ...
6156 INFO: Including run-time hook 'C:\\Users\\Kumbhak\\PycharmProjects\\pythonProject\\.venv
\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
6157 INFO: Including run-time hook 'C:\\Users\\Kumbhak\\PycharmProjects\\pythonProject\\.venv
\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
6159 INFO: Processing pre-find module path hook _pyi_rth_utils from 'C:\\Users\\Kumbhak\\Pych
armProjects\\pythonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_pa
th\\hook-_pyi_rth_utils.py'.
6161 INFO: Loading module hook 'hook-_pyi_rth_utils.py' from 'C:\\Users\\Kumbhak\\PycharmProj
ects\\pythonProject\\.venv\\Lib\\site-packages\\PyInstaller\\hooks'...
6162 INFO: Including run-time hook 'C:\\Users\\Kumbhak\\PycharmProjects\\pythonProject\\.venv
\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
6168 INFO: Looking for dynamic libraries
6457 INFO: Extra DLL search directories (AddDllDirectory): []
6458 INFO: Extra DLL search directories (PATH): []
6728 INFO: Warnings written to C:\Users\Kumbhak\PycharmProjects\pythonProject\build\main\warn
-main.txt
6777 INFO: Graph cross-reference written to C:\Users\Kumbhak\PycharmProjects\pythonProject\bu
ild\main\xref-main.html
6795 INFO: checking PYZ
6795 INFO: Building PYZ because PYZ-00.toc is non existent
6795 INFO: Building PYZ (ZlibArchive) C:\Users\Kumbhak\PycharmProjects\pythonProject\build\ma
in\PYZ-00.pyz
7280 INFO: Building PYZ (ZlibArchive) C:\Users\Kumbhak\PycharmProjects\pythonProject\build\ma
in\PYZ-00.pyz completed successfully.
7292 INFO: checking PKG
7292 INFO: Building PKG because PKG-00.toc is non existent
7293 INFO: Building PKG (CArchive) main.pkg
8981 INFO: Building PKG (CArchive) main.pkg completed successfully.
8983 INFO: Bootloader C:\Users\Kumbhak\PycharmProjects\pythonProject\.venv\Lib\site-packages\
PyInstaller\bootloader\Windows-64bit-intel\run.exe
8983 INFO: checking EXE
8984 INFO: Building EXE because EXE-00.toc is non existent
8984 INFO: Building EXE from EXE-00.toc
8984 INFO: Copying bootloader EXE to C:\Users\Kumbhak\PycharmProjects\pythonProject\dist\main
.exe
8999 INFO: Copying icon to EXE
9002 INFO: Copying 0 resources to EXE
9002 INFO: Embedding manifest in EXE
9006 INFO: Appending PKG archive to EXE
9014 INFO: Fixing EXE headers
9070 INFO: Building EXE from EXE-00.toc completed successfully.
但是,运行文件时,我会得到此错误
File "main.py", line 49, in <module>
File "asyncio\runners.py", line 194, in run
File "asyncio\runners.py", line 118, in run
File "asyncio\base_events.py", line 685, in run_until_complete
File "main.py", line 44, in main
File "main.py", line 32, in loadCommands
FileNotFoundError: [WinError 3] The system cannot find the path specified: './commands/'
[2772] Failed to execute script 'main' due to unhandled exception!
我的项目结构如下(附加图像) 在此处输入图像描述
我有什么可以将EXE包含在构建中的文件夹吗?
我期望有一个带有文件的工作EXE。