PyCharm & VS Code Setup
An IDE (integrated development environment) gives you autocomplete, error highlighting, a run button and a debugger. This lesson sets up the two most popular free choices, PyCharm and Visual Studio Code.
- Create a Python project in PyCharm
- Set up VS Code with the Python extension
- Select the right interpreter
- Run and debug a script with breakpoints
Which editor should you choose?
| PyCharm (Community or Pro) | VS Code + Python extension | |
|---|---|---|
| Made for | Python only | Many languages |
| Setup | Works out of the box | Install the Python extension |
| Strengths | Refactoring, inspections, test runner | Lightweight, huge extension library |
| Best for | Python-focused learners and teams | People who also write JavaScript, YAML, etc. |
Both are free for learning. Pick one and stick with it while you learn; the Python you write is the same.
Set up PyCharm
- Download PyCharm from jetbrains.com and install it.
- Click New Project. Give it a name such as
python-practice. - Under Interpreter type choose Project venv. PyCharm creates a virtual environment (a private copy of Python for this project) in a
.venvfolder. - Click Create. Right-click the project folder, choose New > Python File, and name it
first.py. - Paste the program below and click the green Run arrow next to the first line.
Set up VS Code
- Install Visual Studio Code from code.visualstudio.com.
- Open the Extensions view (Ctrl+Shift+X), search for Python and install the extension published by Microsoft. It also installs Pylance for autocomplete.
- Use File > Open Folder to open an empty folder for your practice files.
- Press Ctrl+Shift+P, run Python: Create Environment, choose Venv and your installed Python.
- Create
first.py, paste the program below and press the Run Python File triangle in the top right.
Your first program in the IDE
total = 0for price in [120, 80, 45]: total = total + price print("Running total:", total) print("Final total:", total)Running total: 120 Running total: 200 Running total: 245 Final total: 245
The Run window shows the same output as the terminal. If you see a ModuleNotFoundError for a package you installed, the IDE is using a different interpreter. Check the interpreter name in the bottom-right status bar.
Debug with a breakpoint
A breakpoint pauses the program on a line so you can inspect variables.
- Click in the gutter left of the line
total = total + price. A red dot appears. - Start the program with Debug (the bug icon) instead of Run.
- The program stops at the red dot. The Variables panel shows
priceandtotal. - Press Step Over (F8 in PyCharm, F10 in VS Code) to run one line at a time and watch
totalgrow.
Debugging is the fastest way to understand someone else’s code, including the practice program solutions on this site. Step through a solution and watch each variable change.
Useful shortcuts
| Action | PyCharm | VS Code |
|---|---|---|
| Run current file | Shift+F10 | Ctrl+F5 |
| Debug | Shift+F9 | F5 |
| Comment / uncomment line | Ctrl+/ | Ctrl+/ |
| Reformat code | Ctrl+Alt+L | Shift+Alt+F |
| Find anything | Shift Shift | Ctrl+P |
Check your understanding
Quick quiz
1. What does a virtual environment give your project?
A venv keeps each project’s packages separate, so upgrading a package for one project cannot break another.
2. Where do you set a breakpoint?
Click the gutter left of a line; the debugger pauses there.
3. A package works in the terminal but the IDE says ModuleNotFoundError. What is the likely cause?
Each interpreter has its own packages. Select the same interpreter (or venv) in the IDE.
Program Practice
Create a basic-programs folder in your project and solve each program in its own file.
40 Python Basic Programs
Every program has a step-by-step explanation, colour-coded code and its real output.
IDE setup FAQ
Is PyCharm Community Edition free?
Yes. PyCharm has a free tier for Python development, and VS Code with the Python extension is free as well.
Can I use IDLE instead?
Yes. IDLE comes with Python and is fine for small scripts. Move to PyCharm or VS Code when you want a debugger, a test runner and Git support.
What is a Python interpreter in PyCharm?
It is the Python executable PyCharm uses to run your code, usually the one inside the project’s .venv folder. You can change it in Settings > Project > Python Interpreter.