Closed Georglider closed 4 months ago
Can you please provide all of the step required to reproduce the issue?
Here's the code for reproduction. It turns on your mobile hotspot and prints whether it was successful or not
import asyncio
import winrt.windows.networking.networkoperators as no
import winrt.windows.networking.connectivity as co
async def enable():
try:
info = co.NetworkInformation.get_internet_connection_profile()
manager = no.NetworkOperatorTetheringManager.create_from_connection_profile(info)
state = manager.tethering_operational_state
if state == no.TetheringOperationalState.ON:
return "WAS ALREADY ENABLED"
elif state == no.TetheringOperationalState.OFF:
ioAsync = await manager.start_tethering_async()
if ioAsync.status == 0:
return "SUCCESSFULLY ENABLED"
return "COULDN'T ENABLE:( " + ioAsync.additional_error_message
elif state == no.TetheringOperationalState.IN_TRANSITION:
return "PROCESS..."
else:
return "SOMETHING WENT WRONG..."
except:
return "SOMETHING WENT WRONG... (EXCEPTION)"
async def main():
info = await enable()
print(info)
asyncio.run(main())
To make it an exe file I use: pyinstaller reproduction.py --onefile --paths \.venv\Lib\site-packages
or pyinstaller reproduction.py --onefile --paths \.venv\Lib\site-packages --hidden-import winrt._winrt --debug=imports
for debug logging
And libraries list for winrt:
I tried this today and was not able to reproduce the problem. The .exe created successfully.
pyinstaller --version
6.5.0
I have encountered with ImportError while I was converting my python program to windows executable file:
I have tried including
winrt._winrt
as hiddenimports param, but it didn't change anything. Is there anything that I'm missing? Thanks in advance!