I cant hide python exe file console [duplicate] - python

This question already has answers here:
How do I hide the console when I use os.system() or subprocess.call()?
(5 answers)
Closed 3 years ago.
I wrote a script , this script modify some files on system.
I used this lib with no console option but when i run script some terminals show up for 1 second and then they will hide.
I used Os.system() in my code.
What should i do to run the script completely silent?

If you name your files with the ".pyw" extension, then windows will execute them with the pythonw.exe interpreter. This will not open the cmd console for running your script.

Related

How to execute program or batch file? [duplicate]

This question already has answers here:
Run a .bat file using python code
(9 answers)
Closed 2 years ago.
I have installed PyCharm to using Python language on Windows 10.
I'm trying to execute command from Linux command in PyCharm, I used this code:
import subprocess
subprocess.run("cat",shell=True,text=True)
But I get this error:
'cat' is not recognized as an internal or external command, operable program or batch file.
I want to execute several commands another such as this example, but all commands raise the same error. How to solve this?
Cat is a binary included in Unix systems, since windows isn't based on Unix, it wouldn't work. You should rather try the TYPE command in Windows

How do I input data into a command prompt from within python 2.7 [duplicate]

This question already has answers here:
Running windows shell commands with python
(7 answers)
Closed 4 years ago.
I want to open a cmd and then input data into the command line from python. I plan to call PEST calibration software to open from within python and I want to start by opening a cmd.
I am using Python 2.7 and so subprocess doesn't seem to work. I have tried os.system('cmd') and I can open the prompt but I can't input any data.
import os
os.system('cmd')
You should be able to pass the exact resulting string to os.system(). Ex:
os.system('notepad.exe')
In other words, os.system behaves the same way a console would.

Run python-script from CMD - windows [duplicate]

This question already has answers here:
How to execute Python scripts in Windows?
(9 answers)
Closed 6 years ago.
I want to run my python script without the python keyword at the beginning.
Example :
I don't want python script.py.
I want script.py
The problem is that when I run it how I want the script opens in a text editor, and it doesn't run in the console...
Why?
I just had to set the default opening of the file with python.exe,
By default it was with VS Code.

How do I stop the command prompt from appearing when I run my Python executable? [duplicate]

This question already has answers here:
Hiding console window of Python GUI app with py2exe
(4 answers)
Closed 7 years ago.
I compiled a Python GUI program using py2exe, and it works, but when I run it the command prompt appears in addition to my program window. I have read that I should change the python.exe file to the pythonw.exe file, but there isn't even a Python.exe file in the dist folder to begin with. Compiling a .pyw version of the file also does not fix this. How would I prevent this from happening?
Duplicate
You didn't post any code (which you should do), but I suspect you're using "console" instead of "windows" in setup.py.

Using arguments in python [duplicate]

This question already has answers here:
How to read/process command line arguments?
(22 answers)
Closed 8 years ago.
I wrote a code using Python in Geany within windows and I'm using arguments in the code. I execute the program within the Geany so I don't know how to use arguments.
How could I convert the program to be be run as a standalone system, not to be run from within an IDE.
how could I use terminal in windows to run the code like this :
John~/home/args -> ./test.py -h
In Notepad, write what you would in terminal...
python test.py -h
Save it as a .bat file... Then you can run the bat file :)
PS. This goes for anything you wish to run in CMD

Categories

Resources