How to hide black cmd windows popping up when programs are executed

Viewed 132

I made a python code which executes polygon.exe program like this:

    import os

    makecommand = "polygon -e 25 -l 25 pri 6 > hexagon.off"
    os.system(makecommand)

Then black cmd window pops up which implies that the polygon.exe program is working well. Now, I want to hide the black cmd window that pops up when I run the python code.

I also tried using subprocess like this,

    import subprocess

    makecommand = "polygon -e 25 -l 25 pri 6 > hexagon.off"
    subprocess.run(makecommand)

but then the polygon.exe program was not executed and the wanted hexagon.off file was missing.

Is there any way to hide the black cmd window popping up in Python when programs are executed? (For your information, polygon.exe program is a part of Antiprism project.)

1 Answers

if you want to hide the cmd when you execute the python file you just need to rename it to file.pyw

Related