When I try to create an executable with auto_py_to_exe it builds fine, but when I run it it throws an error:
Failed to execute script 'main' due to unhandled exception: 'NoneType' object has no attribute 'write'
Traceback (most recent call last):
File "main.py", line 1, 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'
The 'command' auto_py_to_exe runs is:
pyinstaller --noconfirm --onedir --windowed --add-data "web folder path" "main.py path"
Project folder looks like this:
main.py
web
|-main.html
|-main.css
|-main.js
The files are following:
main.py
import eel
eel.init('./web')
eel.start('./main.html')
main.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./main.css">
<script src="./main.js" defer></script>
<title>Document</title>
</head>
<body>
<p class="text">Text</p>
</body>
</html>
main.css
.text {
color: white;
}
main.js
document.body.style.backgroundColor = '#000'
I also tried to run just the command as following, still the same error:
python -m PyInstaller --onedir --windowed --add-data "C:\Users\fused\Desktop\test\web:web" "C:\Users\fused\Desktop\test\main.py"