import issue when freezing scripts
when freezing the script
import winloop
import asyncio
async def hello():
print("Hello")
async def main():
tasks = []
for i in range(10):
tasks.append(hello())
await asyncio.gather(*tasks)
if __name__ == '__main__':
winloop.install()
asyncio.run(main())
with pyinstaller with the following option pyinstaller --onefile main.py and nuitka with nuitka --onefile --remove-output main.py
both the frozen pyinstaller exe and the compiled nuitka exe return errors along the lines of
Traceback (most recent call last):
File "main.py", line 1, in <module>
import winloop
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "winloop\__init__.py", line 7, in <module>
File "winloop\\loop.pyx", line 30, in init winloop.loop
ImportError: cannot import name _noop
[9352] Failed to execute script 'main' due to unhandled exception!
``` for pyinstaller and ```
Traceback (most recent call last):
File "C:\Users\Divine\AppData\Local\Temp\ONEFIL~1\main.py", line 1, in <module>
import winloop
File "C:\Users\Divine\AppData\Local\Temp\ONEFIL~1\winloop\__init__.py", line 7, in <module winloop>
File "winloop\\loop.pyx", line 30, in init winloop.loop
ImportError: cannot import name _noop``` for nuitka, the same commands work to freeze uvloop into executable files in linux.
The problem is that I haven’t written the special hook file yet
for this and I already mentioned how in the readme that
this was going to need to be written soon. The files
that need to be reached are _noop and I believe
there are A few __init__ files as well.
I will see if I can figure this out when I have
the chance but I am willing to let anyone else come
in and make a pull request with the hook file required
if I don’t get to developing this needed feature in time.
for nuitka it won't be needed as of it's next pre-release i opened a PR and added an implicit dependency nuitka needs, now it builds it's exes just fine. https://github.com/Nuitka/Nuitka/pull/2536#issue-1985187965 i couldn't figure it out for pyinstaller though.
for nuitka it won't be needed as of it's next pre-release i opened a PR and added an implicit dependency nuitka needs, now it builds it's exes just fine. Nuitka/Nuitka#2536 (comment) i couldn't figure it out for pyinstaller though.
Sorry for the long wait on the update for this problem two year later but here's my simple solution for pyinstaller.
You can setup a hidden import for the winloop._noop module which solves the problem.