问题描述
由于某些原因,如果您使用pyppeteer并尝试使用Pyinstaller进行构建,它将无法正常工作。
(node:13756) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
at Client.<anonymous> (C:\Users\Topsmoks\Desktop\miz - copy\index.js:37:17)
at Client.emit (events.js:314:20)
at MessageCreateAction.handle (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (C:\Users\Topsmoks\Desktop\miz - copy\node_modules\ws\lib\websocket.js:797:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13756) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13756) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
现在,使用Pyinstaller将其构建为EXE。
from pyppeteer import launch
import asyncio
async def browserLaunch():
browser = await launch(headless=False,handleSIGINT=False,handleSIGTERM=False,handleSIGHUP=False,args=['--start-maximized'])
page = (await browser.pages())[0]
await page.goto("http://google.com")
asyncio.set_event_loop(asyncio.new_event_loop())
asyncio.get_event_loop().run_until_complete(browserLaunch())
启动可执行文件后,这将导致“无法执行脚本”错误。使其正常工作的唯一方法是在控制台或禁用--onefile的情况下进行构建。
pyinstaller --onefile -w browserTest.py
或
pyinstaller --onefile browserTest.py
但是,将“ -w”和“ --onefile”组合使用会导致脚本不起作用。我一直在互联网上搜寻无法找到答案的问题,还问reddit r / learnpython,他们也找不到解决方案。有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)