filmov
tv
PyInstaller --noconsole failed to execute script error Solution
![preview_player](https://i.ytimg.com/vi/oLpBd-2fmmg/maxresdefault.jpg)
Показать описание
Solution for PyInstaller failed to execute script error (noconsole).
Solution for Unable to find file path:
def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
Add this code on top of your code, Now replace your filepath with resource_path(filename)
Note: Your file should be in same folder where your python script is present.
def subprocess_args(include_stdout=True):
if hasattr(subprocess, 'STARTUPINFO'):
si = subprocess.STARTUPINFO()
else:
si = None
env = None
if include_stdout:
ret = {'stdout': subprocess.PIPE}
else:
ret = {}
'stderr': subprocess.PIPE,
'startupinfo': si,
'env': env })
return ret
Now **subprocess_args(False)) in your subprocess function code.
Solution for subprocess.Popen:
import subprocess
"""Now my Python code can exit, and none of its file handles will remain open."""
Also you need to include your external files in pyinstaller by --add-data or PyInstaller GUI mode ,
Solution for Unable to find file path:
def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
Add this code on top of your code, Now replace your filepath with resource_path(filename)
Note: Your file should be in same folder where your python script is present.
def subprocess_args(include_stdout=True):
if hasattr(subprocess, 'STARTUPINFO'):
si = subprocess.STARTUPINFO()
else:
si = None
env = None
if include_stdout:
ret = {'stdout': subprocess.PIPE}
else:
ret = {}
'stderr': subprocess.PIPE,
'startupinfo': si,
'env': env })
return ret
Now **subprocess_args(False)) in your subprocess function code.
Solution for subprocess.Popen:
import subprocess
"""Now my Python code can exit, and none of its file handles will remain open."""
Also you need to include your external files in pyinstaller by --add-data or PyInstaller GUI mode ,