只需尝试使用pyinstaller(-V 4.1(转换"Hello World"程序(.py->.exe(
使用Python 3.9.1
::Windows 10
在正常cmd中运行这是错误消息的摘要:
D:> pyinstaller hello_world.py
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.')
我看到其他帖子建议在虚拟环境中运行pyinstaller
。这将继续运行,但仍会因错误而中断。在venv中运行,这是错误消息的摘要:
(test_env) D:> pyinstaller hello_world.py
5824 WARNING: Can not get binary dependencies for file: C:Users%User%AppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0python.exe
5825 WARNING: Reason: 'The file is empty'
OSError: Python library not found: libpython39m.dll, libpython3.9.dll, libpython3.9m.dll, python39.dll, libpython39.dll
提前感谢您,我确信这是一个被忽视的简单修复
我收到了同样的错误,我的案例中的问题是使用了Microsoft Store中的python。因此,我再次从python网站下载了python,并将其安装在一个特定的目录(类似于:C:pathtomydirectory
在此之后,您唯一需要做的就是使用-p
标志运行虚拟环境(考虑到您的hello_world.py
在D:
上(:
D:> virtualenv -p C:pathtomydirectorypython D:
然后在该环境上安装pyinstaller
:
D:> Scriptsactivate
(test_env) D:> pip install pyinstaller
它就在那里:
(test_env) D:> pyinstaller hello_world.py
(test_env) D:> cd dist
(test_env) D:> .hello_world