TransWikia.com

Moving from Geany to Sublime Text 3: how to run Python scripts in command prompt?

Super User Asked on January 1, 2022

I’ve been coding in Python 3.6 using the Geany editor for a while. When I run scripts in Geany, a Windows command prompt running Python will pop up and run the script. This I did using the build command python -i "%f" in Geany.

Now I’ve been trying out a different editor: Sublime Text 3. However, I find the in-built console doesn’t work well for my needs, so as with Geany I’d like a Windows command prompt to pop up and run my code. How do I do this in Sublime Text 3?

One Answer

Try this thing out: You might have created the python file in some directory just double click on it. There is one issue with this once the program ends the CMD window closes so try to give enough delay so that you could verify your output like this:

import time

and put the following as your last line

time.sleep(seconds) # put 120 like that i.e. 2 minutes it will wait before closing CMD

Or try this Open CMD and open the directory to your python file using cd to change directory, e: or d: to choose drive cd.. to go back by one step to the parent directory if directed to your directory

python thefile.py

will open the python file with the name thefile.py if the file is on desktop just type python thefile.py in the cmd.

Answered by Kamalesh Pathy on January 1, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP