Habe mich jetzt mit dem Starten von Pyinstaller via subprocess beschäftigt.
Später füge ich dann noch ein tk.Text für die ausgabe von pyinstaller hinzu.
Zunächst wollte ich erst einmal pyinstaller mit subprocess laufen lassen und die ausgabe an stderr/stdout zuweisen.
Bin aber neuling, bei der benutzung von subprocess.
In meinem Code:
Code: Alles auswählen
import os
import shutil
import subprocess
import PyInstaller.__main__
SRC_FILE_PATH = "C:/Users/chris/Documents/PyCharm/Hot Run/main.py"
SRC_SPLIT_PATH = SRC_FILE_PATH.split('/')
SRC_BASE_NAME = SRC_SPLIT_PATH.pop(-1)
SRC_PATH = '/'.join(SRC_SPLIT_PATH)
TRG_FOLDER_PATH = "C:/Users/chris/Desktop/HOT RUNNER"
TRG_SPLIT_PATH = TRG_FOLDER_PATH.split('/')
TRG_BASE_NAME = TRG_SPLIT_PATH.pop(-1)
TRG_PATH = '/'.join(TRG_SPLIT_PATH)
SRC_ICN_FILE = "C:/Users/chris/Documents/PyCharm/Hot Run/images/icon/minion.ico"
SRC_IMG_FOLDER = "C:/Users/chris/Documents/PyCharm/Hot Run/images"
SRC_SND_FOLDER = "C:/Users/chris/Documents/PyCharm/Hot Run/sounds"
def copy_additives(src_path, trg_path):
if os.path.isdir(src_path):
if not os.path.isdir(trg_path):
shutil.copytree(src_path, trg_path, symlinks=False, ignore=None)
else:
shutil.copy2(src_path, trg_path)
for item in os.listdir(SRC_PATH):
SOURCE_PATH = os.path.join(SRC_PATH, item).replace('\\', '/')
if SRC_IMG_FOLDER == SOURCE_PATH:
TRG_IMG_FOLDER = os.path.join(TRG_PATH, TRG_BASE_NAME, item).replace('\\', '/')
copy_additives(SRC_IMG_FOLDER, TRG_IMG_FOLDER)
elif SRC_SND_FOLDER == SOURCE_PATH:
TRG_SND_FOLDER = os.path.join(TRG_PATH, TRG_BASE_NAME, item).replace('\\', '/')
copy_additives(SRC_SND_FOLDER, TRG_SND_FOLDER)
os.chdir(SRC_PATH)
subprocess.call(
PyInstaller.__main__.run([
SRC_BASE_NAME,
'--onedir',
'--onefile',
'--windowed',
'--noconsole',
'--name=' + TRG_BASE_NAME,
'--icon=' + SRC_ICN_FILE,
'--distpath=' + TRG_FOLDER_PATH,
'--specpath=' + TRG_FOLDER_PATH
]))
erhalte ich die Ausnahme:
Code: Alles auswählen
[...]
7607 INFO: Building EXE from EXE-00.toc completed successfully.
Traceback (most recent call last):
File "C:\Users\chris\Documents\PyCharm\Create EXE-File\test.py", line 41, in <module>
subprocess.call(PyInstaller.__main__.run([
File "C:\Program Files\Python39\lib\subprocess.py", line 349, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Program Files\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python39\lib\subprocess.py", line 1356, in _execute_child
args = list2cmdline(args)
File "C:\Program Files\Python39\lib\subprocess.py", line 561, in list2cmdline
for arg in map(os.fsdecode, seq):
TypeError: 'NoneType' object is not iterable
Process finished with exit code 1
Ich weiß nicht genau, wodurch der Fehler verursacht wird.
@ DeaD_EyE: Pyinstaller mit Popen starten und stderr/stdout der PIPE zuweisen und ja so auch noch nicht umgesetzt.
Ohne subprocess, sondern nur mit
Code: Alles auswählen
PyInstaller.__main__.run([
SRC_BASE_NAME,
'--onedir',
'--onefile',
'--windowed',
'--noconsole',
'--name=' + TRG_BASE_NAME,
'--icon=' + SRC_ICN_FILE,
'--distpath=' + TRG_FOLDER_PATH,
'--specpath=' + TRG_FOLDER_PATH
])
läuft der Code einwandfrei.