Pyinstaller -w exe still opening terminals in Windows

Viewed 46

I ran this command to convert my script from .py to .exe:

pyinstaller.exe -w -i .\icon.png --add-data='icon.png;.' .\gui_script.py

and after adding in some poorly added packages the GUI opens via my tkinter script. But when I run code using the tkinter window in Windows, every time there's a subprocess.run or os.system function it opens up a new terminal window. Is there any way to suppress these? Or at least make them minimized or not noticeable?

Here's a piece of the gui_script.py that combines two files which opens an external terminal window.

import os

os.system('copy cDNA.fa+ncRNA.fa transcriptome.fa /b')
1 Answers

I started using python tools for the merging of files:

with open('transcriptome.fa','wb') as transcriptome_file:
        for fasta_file in ['cDNA.fa','ncRNA.fa']:
            with open(fasta_file,'rb') as current_fasta:
                shutil.copyfileobj(current_fasta, transcriptome_file)

as well as downloading of larger files:

with requests.get('http://ftp.ensembl.org/pub/current_fasta/'+species+'/cdna/'+cDNA_file_name, stream=True) as cDNA_request:
        with open('cDNA.fa.gz', 'wb') as cDNA_gz_file:
            shutil.copyfileobj(cDNA_request.raw, cDNA_gz_file)

Despite this I still need to run an external program, blast, so there I used subprocess.run with the creationflag = subprocess.CREATE_NO_WINDOW argument like this:

if os.name == 'nt':
    blast_db_run = subprocess.run(['makeblastdb',
                            '-in', fasta_file,
                            '-dbtype', 'nucl',
                            '-out','blast_db'],
                            capture_output=True, 
                            creationflags = subprocess.CREATE_NO_WINDOW)

Used the if statement since creationflags doesn't work in a non-windows environment apparently.

Related