The integrated terminal is a command-line window inside PyCharm. It helps you navigate project folders and run Python commands without leaving the IDE.
Understanding the Concept
Open the Terminal tool window from the View > Tool Windows menu or the bottom tool strip. A prompt shows that the shell is ready for commands. Check the current directory before running a file, because relative file paths depend on that location. PyCharm may automatically activate the project virtual environment when the terminal opens, depending on settings. This changes which python and pip commands are selected.
When and Why You Would Use This
Terminal commands are shell instructions, not lines to insert into a .py file. On Windows the shell might be PowerShell; on macOS/Linux it may be zsh or bash. The commands below are cross-platform only when the executable is available on PATH.
Practical Example
python --version
python -c "print(6 * 7)"
python -m pip --version
Understanding the Example
The first reports the selected interpreter, the second prints 42, and the last reports the pip version associated with that interpreter if pip is installed. If these commands select another Python version, inspect the active environment first.
Try It Yourself
Open Terminal, check the current directory, and run a one-line arithmetic command.
Common Beginner Mistakes
- Pasting shell commands into Python source code. Use the Terminal window for these commands.
- Assuming the terminal always activates the project environment. Verify the version and executable.
- Running a script from the wrong directory and mistaking a file-not-found error for a broken installation.
Key Takeaways
- The integrated terminal runs shell commands inside PyCharm.
- Current directory and active environment affect command behavior.
python -m pipaddresses the pip module for the selected interpreter.