尝试将.py
文件转换为.exe
文件时,我一直收到以下错误消息。奇怪的是,PyInstaller
在该程序的早期版本(位于其他文件夹中)上可以正常工作。我一直无法找到解决方案,而且我对这些信息还不够了解,无法理解错误消息。任何帮助将不胜感激。
C:\Users\janca\source\repos\Super Random Group Creator>pyinstaller --onefile -w the_random_group_creator.py
62 INFO: PyInstaller: 3.5
62 INFO: Python: 3.7.4
62 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.spec
62 INFO: UPX is not available.
62 INFO: Extending PYTHONPATH with paths
['C:\\Users\\janca\\source\\repos',
'C:\\Users\\janca\\source\\repos\\Super Random Group Creator']
62 INFO: checking Analysis
62 INFO: Building Analysis because Analysis-00.toc is non existent
62 INFO: Initializing module dependency graph...
78 INFO: Initializing module graph hooks...
78 INFO: Analyzing base_library.zip ...
3467 INFO: running Analysis Analysis-00.toc
3467 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\program files (x86)\microsoft visual studio\shared\python37_64\python.exe
3671 INFO: Caching module hooks...
3671 INFO: Analyzing C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.py
3795 INFO: Loading module hooks...
3795 INFO: Loading module hook "hook-encodings.py"...
3858 INFO: Loading module hook "hook-pydoc.py"...
3858 INFO: Loading module hook "hook-PySide2.py"...
4436 INFO: Loading module hook "hook-PySide2.QtCore.py"...
4639 INFO: Loading module hook "hook-PySide2.QtGui.py"...
4811 INFO: Loading module hook "hook-PySide2.QtNetwork.py"...
5248 INFO: Loading module hook "hook-PySide2.QtWidgets.py"...
5514 INFO: Loading module hook "hook-xml.py"...
5764 INFO: Looking for ctypes DLLs
5764 INFO: Analyzing run-time hooks ...
5764 INFO: Including run-time hook 'pyi_rth_pyside2.py'
5764 INFO: Looking for dynamic libraries
Traceback (most recent call last):
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
raise make_error(function, function_name)
OSError: [WinError 2] The system cannot find the file specified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\janca\source\repos\Super Random Group Creator\the_random_group_creator.spec", line 17, in <module>
noarchive=False)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
self.__postinit__()
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\building\build_main.py", line 567, in assemble
redirects=self.binding_redirects))
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
res = GetManifestResources(pth)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'LoadLibraryExW', 'The system cannot find the file specified.')
更新:我将相关的源文件复制到另一个目录并运行PyInstaller
。那行得通。看来问题似乎与Visual Studio创建的.pyproj
文件有关。