You can write Python in any plain text editor, even Notepad. But a proper code editor or IDE (Integrated Development Environment) makes programming much easier. It highlights syntax, suggests code as you type, points out mistakes before you run, and lets you run and debug your program with one click.
In this tutorial, you’ll set up the three most popular tools for Python: Visual Studio Code (VS Code), PyCharm, and Jupyter notebooks. For each one, you’ll install it, connect it to Python, create a virtual environment, and run and debug your first program.
Before you start: Python must already be installed on your computer. If it isn’t, follow How to Install Python on Windows, macOS, and Linux first. Editors don’t include Python. They use the interpreter you installed.
Key terms used in this article:
- Code editor: A program for writing code, with helpful features such as color highlighting.
- IDE: An Integrated Development Environment, a code editor with many extra built-in tools.
- Interpreter: The Python program that runs your code. Your editor needs to know which one to use.
- Virtual environment: A separate, private space for one project’s packages, usually in a folder named
.venv. - Debugger: A tool that pauses your program so you can look at what’s happening inside it.
- Extension: An add-on that gives an editor new features.
Table of contents
Editor vs IDE vs notebook
These three tools work in different ways:
- Code editor (VS Code): A lightweight editor that supports many languages. You add Python features through extensions.
- IDE (PyCharm): A full development environment built specifically for Python, with refactoring, testing, debugging, and project management built in.
- Notebook (Jupyter): A document in your browser that mixes code, output, charts, and notes. You run code in small pieces called cells and see the result right below each one.
| Feature | VS Code | PyCharm | Jupyter |
|---|---|---|---|
| Type | Code editor with extensions | Python IDE | Browser-based notebook |
| Cost | Free | Core features free, Pro features need a subscription | Free |
| Speed and size | Lightweight, starts fast | Heavier, uses more memory | Light, runs in a browser |
| Best for | General programming, many languages | Large Python projects | Data analysis, learning, experiments |
| Debugger | Yes (Python extension) | Yes, built in | Basic |
| File type | .py (and .ipynb) | .py (and .ipynb) | .ipynb |
Which one should you choose?
- Beginners and general use: Start with VS Code. It’s free, fast, and you can use it for other languages later.
- Bigger Python applications (such as Django or Flask projects): PyCharm gives you the most Python-specific help out of the box.
- Data science, machine learning, and quick experiments: Use Jupyter, either on its own or inside VS Code or PyCharm.
You don’t have to pick only one. Many developers write applications in VS Code or PyCharm and explore data in Jupyter.
Set up VS Code for Python
Step 1: Install VS Code
- Go to code.visualstudio.com and download the installer for your operating system.
- Windows: Run the installer. On the Select Additional Tasks screen, check Add to PATH and Add “Open with Code” action. These let you open folders in VS Code from the terminal and File Explorer.
- macOS: Open the downloaded file and drag Visual Studio Code into your Applications folder. To use the
codecommand in Terminal, open VS Code, press Cmd + Shift + P, and run Shell Command: Install ‘code’ command in PATH. - Linux: Download the
.deb(Ubuntu/Debian) or.rpm(Fedora/RHEL) package and install it with your package manager, for examplesudo apt install ./code_*.deb.
Step 2: Install the Python extension
VS Code needs Microsoft’s Python extension to understand Python.
- Open VS Code and click the Extensions icon in the left sidebar, or press Ctrl + Shift + X (macOS: Cmd + Shift + X).
- Search for Python.
- Install the extension named Python published by Microsoft.
This extension automatically adds two helpers: Pylance, which suggests code as you type and underlines mistakes, and Python Debugger, which lets you pause your program to find problems.
Step 3: Open a project folder
VS Code works best when you open a whole folder rather than single files. Create a folder for your project and open it:
Or use File › Open Folder from the menu. If VS Code asks whether you trust the authors of the files in this folder, click Yes, I trust the authors for your own folders.
Step 4: Create a virtual environment and select the interpreter
The interpreter is the Python program VS Code uses to run your code. It’s best to give each project its own virtual environment, so packages you install for one project don’t affect others.
- Open the Command Palette with Ctrl + Shift + P (macOS: Cmd + Shift + P).
- Type and select Python: Create Environment.
- Choose Venv, then choose the Python version you installed (for example, Python 3.15).
- VS Code creates a
.venvfolder in your project and selects it as the interpreter automatically.
To switch interpreters later, open the Command Palette and run Python: Select Interpreter. The selected interpreter is also shown in the bottom-right corner of the status bar when a Python file is open. You can click it to change it.
You can also create the environment yourself in the built-in terminal (View › Terminal). VS Code detects it and asks whether to use it:
Step 5: Write and run a Python file
Click the New File icon in the Explorer sidebar, name it hello.py, and add this code:
Run it in one of these ways:
- Click the Run Python File button (â–·) in the top-right corner of the editor.
- Right-click in the editor and choose Run Python › Run Python File in Terminal.
- Type
python hello.pyin the integrated terminal. Open it with Ctrl + ` (backtick).
Output (in the terminal panel):
What is your name? Jessa Hello, Jessa! VS Code is ready for Python.
Tip: Select one or more lines and press Shift + Enter to run just those lines in a Python terminal. This is handy for testing small pieces of code.
Step 6: Debug your code
A debugger lets you pause your program on a specific line and inspect variable values. It’s the fastest way to find out why code doesn’t do what you expect. Replace the contents of hello.py with:
- Click in the margin to the left of line 5 (
total = total + score). A red dot appears. This is a breakpoint. - Press F5 and choose Python Debugger: Current File.
- The program pauses at the breakpoint. The Variables panel on the left shows the current values of
score,total, andscores. - Press F5 (Continue) to run to the next pause, F10 to step over a line, or Shift + F5 to stop debugging.
Useful VS Code shortcuts
You don’t need to memorize these, but they save time once you start coding regularly:
| Action | Windows / Linux | macOS |
|---|---|---|
| Command Palette | Ctrl + Shift + P | Cmd + Shift + P |
| Open or close terminal | Ctrl + ` | Ctrl + ` |
| Start debugging | F5 | F5 |
| Run without debugging | Ctrl + F5 | Ctrl + F5 |
| Comment or uncomment line | Ctrl + / | Cmd + / |
| Go to definition | F12 | F12 |
| Rename a variable everywhere | F2 | F2 |
Set up PyCharm for Python
PyCharm, made by JetBrains, is an IDE designed only for Python. Since version 2025.1, PyCharm is a single product: the separate Community and Professional editions were merged. The core features, including Jupyter notebook support, are free. A Pro subscription adds advanced features such as web framework, database, and remote development tools. Each new install starts with a free one-month Pro trial, after which you can keep using the free core features.
Step 1: Install PyCharm
- Go to jetbrains.com/pycharm/download and download PyCharm for your operating system.
- Windows: Run the
.exeinstaller. On the Installation Options screen, you can check Add “bin” folder to the PATH and Create Associations: .py. - macOS: Open the
.dmgfile and drag PyCharm into Applications. Choose the Apple Silicon or Intel download to match your Mac. - Linux: Extract the
.tar.gzfile and runbin/pycharm.sh, or install the Snap package withsudo snap install pycharm --classic.
Step 2: Create a new project
- Start PyCharm and click New Project on the Welcome screen.
- Select Pure Python (or simply Python, depending on your version).
- Enter a project name and location, for example
hello_python. - Under the interpreter settings, choose Project venv to create a new virtual environment inside the project. Pick your installed Python version as the base interpreter. If PyCharm doesn’t find it, click the … button and browse to the Python executable.
- Leave Create a welcome script checked if you want PyCharm to add a sample
main.pyfile. - Click Create.
PyCharm creates the project folder, a .venv virtual environment, and indexes your Python installation. Wait for the progress bar at the bottom to finish so code completion works fully.
Step 3: Run your code
Right-click the project folder in the Project panel, choose New › Python File, and name it hello. PyCharm adds the .py extension. Add this code:
Run the file in one of these ways:
- Click the green Run icon (â–¶) in the gutter next to the code, or in the toolbar at the top.
- Right-click inside the editor and choose Run ‘hello’.
- Press Ctrl + Shift + F10 (macOS: Ctrl + Shift + R).
The Run tool window opens at the bottom and shows:
Hello, Jessa! PyCharm is ready for Python. Process finished with exit code 0
exit code 0 means the program finished without errors.
Step 4: Debug your code
- Click in the gutter next to the line
return f"Hello, ..."to set a breakpoint (a red dot). - Right-click in the editor and choose Debug ‘hello’, or click the bug icon in the toolbar.
- The program pauses at the breakpoint. The Debug tool window shows the value of
nameunder Threads & Variables. - Use F8 to step over, F7 to step into a function, and F9 (macOS: Cmd + Option + R) to resume.
Step 5: Manage the interpreter and packages
- To change the interpreter, open Settings (Windows/Linux: File › Settings; macOS: PyCharm › Settings) and go to Project › Python Interpreter. You can also click the interpreter name in the bottom-right corner of the window.
- To install a package, open the Python Packages tool window (View › Tool Windows › Python Packages), search for the package, and click Install.
- You can also run
pip install package_namein PyCharm’s Terminal tool window. It activates the project’s virtual environment automatically. - If PyCharm underlines an
importin red because the package is missing, hover over it and click Install package.
Set up Jupyter notebooks
Jupyter lets you write and run code in a notebook file (.ipynb) that combines code, its output, charts, and formatted text. It’s the standard tool for data analysis, machine learning experiments, and teaching. JupyterLab is its modern interface. The classic Jupyter Notebook interface is still available too.
Install and start JupyterLab
Install Jupyter inside a virtual environment, just like any other package:
JupyterLab starts a small local server and opens in your web browser, usually at http://localhost:8888/lab. Keep the terminal window open while you work. Press Ctrl + C in the terminal to stop the server when you’re done.
Optional: If you prefer the simpler, older notebook screen, install and start the classic interface instead:
Use a notebook
In JupyterLab, click Python 3 (ipykernel) under Notebook in the Launcher. A new notebook opens with an empty cell. Type code into the cell and press Shift + Enter to run it and move to the next cell.
Cell 1:
Average: 80.0
Cell 2:
[95, 88, 81]
Two things make notebooks different from running a .py file:
- State is shared between cells.
scoreswas created in cell 1 and used in cell 2. The program that keeps this state is called the kernel. - The last expression in a cell is displayed automatically, without
print(). That’s why cell 2 shows the list.
Useful notebook basics:
- Change a cell to Markdown (press Esc, then M) to write headings, notes, and explanations.
- Cells can be run in any order, and the number in
[ ]next to a cell shows the order they actually ran in. If results look wrong, use Kernel › Restart Kernel and Run All Cells to start fresh from the top. - Press Esc, then A or B to insert a cell above or below.
Jupyter inside VS Code and PyCharm
You don’t need to use the browser. Both editors can open and run .ipynb notebooks directly.
VS Code
- Install the Jupyter extension by Microsoft from the Extensions view.
- Run Create: New Jupyter Notebook from the Command Palette, or create a file ending in
.ipynb. - Click Select Kernel in the top-right corner and pick your project’s
.venvenvironment. - If VS Code asks to install
ipykernel, click Install. A notebook needs this package in the environment to run code.
PyCharm
Right-click your project folder, choose New › Jupyter Notebook, and start typing in the first cell. PyCharm uses the project interpreter as the kernel and offers to install the required Jupyter packages if they’re missing. Notebook support is included in PyCharm’s free core features.
Note: If you want to try notebooks without installing anything, Google Colab runs Jupyter notebooks in your browser for free with a Google account.
Troubleshooting common setup problems
1. “Python is not installed” or no interpreter is found
The editor can’t find Python. Check that python --version (or python3 --version) works in a terminal, then restart the editor. In VS Code, run Python: Select Interpreter and choose Enter interpreter path to browse to it manually.
2. “ModuleNotFoundError: No module named …” even though you installed the package
The package was installed into a different Python environment from the one your editor uses. Check which interpreter is selected, then install the package with that interpreter, for example by running python -m pip install package_name in the editor’s built-in terminal with the virtual environment active. Run this to see which Python your code is using:
3. Virtual environment won’t activate in PowerShell (Windows)
If you see an error about running scripts being disabled, allow local scripts for your user account once, then try again:
4. Notebook kernel not found or won’t start
A notebook needs the ipykernel package in the environment it uses. Make sure the right environment is selected (or activated) and run the first command below, then restart the notebook. The second command is optional: it adds the environment to JupyterLab’s kernel list under the name my_project.
Optional extras
You don’t need anything in this section to start coding. Come back to it once you’re comfortable with your editor.
Format your code automatically in VS Code
A formatter tidies up your code’s spacing and layout every time you save. Install the Ruff extension (or Black Formatter) from the Extensions view. Then run Preferences: Open User Settings (JSON) from the Command Palette and add these settings:
If you installed Black Formatter instead, use "ms-python.black-formatter" as the formatter name.
Install PyCharm with JetBrains Toolbox
The free JetBrains Toolbox App installs PyCharm and keeps it up to date automatically. It’s handy if you later use other JetBrains tools too.
Summary
- Install Python first. VS Code, PyCharm, and Jupyter all use the Python interpreter already on your computer.
- VS Code: Install the Python extension by Microsoft. Create a virtual environment with Python: Create Environment, switch with Python: Select Interpreter, run with the â–· button, and debug with breakpoints and F5.
- PyCharm: One unified product with free core features. Create a project with a Project venv interpreter, run with the green â–¶ icon, and debug with the bug icon. Manage packages in the Python Packages tool window.
- Jupyter: Install with
python -m pip install jupyterlaband start withjupyter lab. Run cells with Shift + Enter. Cells share state through the kernel, and the last expression in a cell is displayed automatically. - VS Code and PyCharm can open
.ipynbnotebooks directly. The environment needs theipykernelpackage. - Most setup problems come from the editor using a different Python environment from the one you installed packages into. Check
sys.executableand the selected interpreter.
Next step: Your editor is ready. Now write your first Python program: Hello World.

Leave a Reply