auto-py-to-exe的使用参考一下链接:
链接: python—auto-py-to-exe—.py文件打包成.exe文件最全最详细(用不同的类别做教程)
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<Connection.run() done, defined at playwright\_impl\_connection.py:258> exception=FileNotFoundError(2, '系统找不到指定的文件。', None, 2, None)>
Traceback (most recent call last):
File "playwright\_impl\_connection.py", line 265, in run
File "playwright\_impl\_transport.py", line 127, in connect
File "playwright\_impl\_transport.py", line 116, in connect
File "asyncio\subprocess.py", line 218, in create_subprocess_exec
File "asyncio\base_events.py", line 1680, in subprocess_exec
File "asyncio\windows_events.py", line 394, in _make_subprocess_transport
File "asyncio\base_subprocess.py", line 36, in __init__
File "asyncio\windows_events.py", line 910, in _start
File "asyncio\windows_utils.py", line 153, in __init__
File "subprocess.py", line 1022, in __init__
File "subprocess.py", line 1491, in _execute_child
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
这个问题在使用auto-py-to-exe打包后,没有把playwright文件夹打包进去,不知道为什么,
我的包安装地址是:C:\Python311\Lib\site-packages\playwright
在 附加文件 -》 添加目录 。里面选择自己playwright安装的文件夹,就可以正常运行
Traceback (most recent call last):
File "demo copy 2.py", line 27, in <module>
File "asyncio\runners.py", line 190, in run
File "asyncio\runners.py", line 118, in run
File "asyncio\base_events.py", line 650, in run_until_complete
File "demo copy 2.py", line 26, in main
File "demo copy 2.py", line 13, in run
File "playwright\async_api\_generated.py", line 14476, in launch
File "playwright\_impl\_browser_type.py", line 93, in launch
File "playwright\_impl\_connection.py", line 61, in send
File "playwright\_impl\_connection.py", line 461, in wrap_api_call
File "playwright\_impl\_connection.py", line 96, in inner_send
playwright._impl._api_types.Error: Executable doesn't exist at C:\Users\86152\AppData\Local\Temp\_MEI244722\playwright\driver\package\.local-browsers\chromium-1060\chrome-win\chrome.exe
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ playwright install ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════╝
[12932] Failed to execute script 'demo copy 2' due to unhandled exception!
这个提示是告知我们没有找到浏览器,因为代码在本地测试通过的,也安装过浏览器,运行没问题,但是打包exe后,系统会把路径换成工作路径:C:\Users\86152\AppData\Local\Temp_MEI244722,和本地运行路径不同,结果导致找不到浏览器,
系统是根据这个路径来寻找的:
C:\Users\86152\AppData\Local\Temp\_MEI244722\playwright\driver\package\.local-browsers\chromium-1060\chrome-win\chrome.exe
找到之前下载浏览器的位置:
我的是下载到:C:\Users\86152\AppData\Local\ms-playwright 文件夹下的