Pytech Resources

Command prompt for the Python developer

Nov 17, 2024

Posted by:

Python at the Command Prompt

In my Python beginners class, besides teaching my students how to use the IDLE editor, I also teach them how to use the command prompt. (For Mac users, it is known as a terminal).

Starting a command prompt on Windows is easy. Just click Start and enter cmd into the search field and click Open. You can also click Pin to Start or Pin to taskbar for convenience in opening a command prompt.

start_cmd

The command prompt will open your user folder which is normally C:\Users\<username>

cmd1

You are ready to enter some commands. Type python and press enter. This will start the Python shell with the triple angle prompts. You can enter some Python statements to try out the shell. To exit the shell press Ctrl-Z followed by Enter.

If you get this message "'python' is not recognized as an internal or external command", it means that you did not check the Add to Path button in the Python installation screen. You can set the path manually which I will cover in a separate blog later or you can reinstall Python and make sure you check Add to Path.

You will need to use the command prompt when you want to install third party libraries such as pandas, jupyter, etc using the pip program.

You can also start Python modules at the command line. For example you can start IDLE from a directory where you save your Python scripts.

cmd_idlelib.idle

IDLE will be started and the default open/save directory will be the directory from which you started it.

dos_commands