PyCharm uses tools installed on your computer to run programs. PyCharm should automatically find the Python you have installed on your computer if installed in a “standard” location.
There are multiple ways to run a program file:
Right-click
anywhere in the code to open the context menu, then select Run [filename]
or Debug [filename]
.Python Debugger
popup, and select default options of subsequent pop-ups until you see the program run in the interactive Terminal at the bottom.Debug
and plain Run
in the future.Shift+F9
(Windows, Linux) or ^D
(Mac) to DebugShift+F10
(Windows, Linux) or ^R
(Mac) to Run without debugging.hello.py
in the pycharm-test
directory if needed and add print("Hello World")
hello.py
using the the context window.When you run your hello.py
program, you should see output in the Debug or Run pane at the bottom. The exact output differ from mine, but you should see Hello World
in there.
PyCharm also has an Integrated Terminal, which is an embedded version of the Command Prompt (Windows) or Terminal (Mac). You can use CLI commands like cd
, ls
, mkdir
, etc.
Open the Integrated Terminal by either:
View → Tool Windows → Terminal
Alt+F12
(Windows, Linux) or Option+F12
(Mac)When you ran your hello.py
program, you should have seen a flurry of output in the Integrated Terminal window at the bottom. What just happened?
python
with your file as an argument.python
runs in the Terminal and prints output.I find it convenient to use this integrated Terminal rather than switching to a another window. Or you may prefer to keep them separate. Do what works for you.
ls
command.cd ~
in the integrated Terminal to switch to your home directory. Notice how the contents of the Project pane do not change. You are only changing the working directory in the Terminal.pycharm-test
directory using cd
commands.touch hello2.py
. Does it appear in the Explorer pane?rm hello2.py
. What happened? What happened in the Project pane?