Question: here's the error: Traceback (most recent call last): File "main.py", line 5, in <module> File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module File "eel\__init__.py", line 8, in <module> File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module File "bottle.py", line 73, in <module> AttributeError: 'NoneType' object has no attribute 'write'  here's the pyinstaller command: pyinstaller --noconfirm --onedir --windowed --icon icon.ico --name "Useful Tools for Windows" --uac-admin --add-data "web;web/" main.py  here's the source code: # Imports system commands import os # Imports eel, a Electron like GUI for Python. import eel eel.init("web") # Fixes Chrome not installed. eel.browsers.set_path( "chrome", "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" ) @eel.expose def openHosts(): os.system( "attrib -r %WINDIR%\system32\drivers\etc\hosts && start notepad.exe %windir%\system32\drivers\etc\hosts" ) @eel.expose def openOfficeAddins(): os.system("explorer.exe %AppData%\Microsoft\AddIns") @eel.expose def openCurrentUserStartMenu(): os.system("explorer.exe %AppData%\Microsoft\Windows\Start Menu") @eel.expose def openAllUserStartMenu(): os.system("explorer.exe C:\ProgramData\Microsoft\Windows\Start Menu") @eel.expose def openSentTo(): os.system("explorer.exe %Appdata%\Microsoft\Windows\SendTo") @eel.expose def openCurrentUserStartup(): os.system("explorer.exe %AppData%\Microsoft\Windows\Start Menu\Programs\Startup") @eel.expose def openAllUsersStartup(): os.system( "explorer.exe C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" ) @eel.expose def openWordStartup(): os.system("explorer.exe %AppData%\Microsoft\Word\STARTUP") @eel.expose def openPSReadLineHistory(): os.system( "notepad %AppData%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" ) @eel.expose def installYouTubeDownloader(): os.system("winget install MoheshwarAmarnathBiswas.YouTubeVideoDownloader") @eel.expose def installPowerToys(): os.system("winget install Microsoft.PowerToys") @eel.expose def installSysInternals(): os.system("winget install --id 9P7KNL5RWT25") @eel.expose def openAccountPictures(): os.system("explorer shell:AccountPictures") @eel.expose def openFolderOptions(): os.system("explorer shell:::{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}") @eel.expose def openInternetOptions(): os.system("explorer shell:::{A3DD4F92-658A-410F-84FD-6FBBBEF2FFFE}") @eel.expose def openSoundOptions(): os.system("explorer shell:::{F2DDFC82-8F12-4CDD-B7DC-D4FE1425AA4D}") @eel.expose def openPowerOptions(): os.system("explorer shell:::{025A5937-A6BE-4686-A844-36FE4BEC8B6D}") @eel.expose def openOptionalFeatures(): os.system("start %WINDIR%\System32\OptionalFeatures.exe") @eel.expose def openControlPanel(): os.system("start control.exe") @eel.expose def wsreset(): os.system("start wsreset.exe") @eel.expose def wureset(): os.system("net stop bits") os.system("net stop wuauserv") os.system("net stop CryptSvc") os.system("net stop msiserver") os.system("del %windir%\SoftwareDistribution") os.system("del %windir%\system32\catroot2") os.system("net start bits") os.system("net start wuauserv") os.system("net start CryptSvc") os.system("net start msiserver") @eel.expose def openGodMode(): os.system("explorer.exe shell:::{ed7ba470-8e54-465e-825c-99712043e01c}") eel.start("index.html")  Full source code: https://github.com/fluentmoheshwar/useful-tools Dependencies used: altgraph==0.17.3 black==22.12.0 bottle==0.12.23 bottle-websocket==0.2.9 cffi==1.15.1 click==8.1.3 colorama==0.4.6 Eel==0.15.1 future==0.18.3 gevent==22.10.2 gevent-websocket==0.10.1 greenlet==2.0.1 mypy-extensions==0.4.3 pathspec==0.10.3 pefile==2022.5.30 platformdirs==2.6.2 pycparser==2.21 pyinstaller==5.7.0 pyinstaller-hooks-contrib==2022.15 pyparsing==3.0.9 pywin32-ctypes==0.2.0 tomli==2.0.1 whichcraft==0.6.1 zope.event==4.6 zope.interface==5.5.2  Using Microsoft Store version of Python: Yes. Using venv: yes. I tried installing wheel and reinstalling dependencies. I tried adding C:\Windows\System32\downlevel to path. I tried recreating venv.

Answer: One of the libraries you are using is attempting to write to sys.stdout and sys.stderr, which are set to None when you run pyinstaller with the -w --windowed or --noconsole options. You need to explicitly set sys.stderr and sys.stdout in your programs code as early as possible to a writeable object like an open file or an io buffer. for example: import sys, io buffer = io.StringIO() sys.stdout = sys.stderr = buffer