PYnative

Practice Coding

  • Python â–¼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Coding Exercises â–¼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • MCQsâ–¼
    • Python MCQ Quizzes
    • Java MCQ Quizzes
    • C++ MCQ Quizzes
  • Compilersâ–¼
    • Online Python Compiler
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » Python » Basics » Setting Up VS Code / PyCharm / Jupyter for Python

Setting Up VS Code / PyCharm / Jupyter for Python

Updated on: December 4, 2026 | Leave a Comment

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
    • Which one should you choose?
  • Set up VS Code for Python
    • Step 1: Install VS Code
    • Step 2: Install the Python extension
    • Step 3: Open a project folder
    • Step 4: Create a virtual environment and select the interpreter
    • Step 5: Write and run a Python file
    • Step 6: Debug your code
    • Useful VS Code shortcuts
  • Set up PyCharm for Python
    • Step 1: Install PyCharm
    • Step 2: Create a new project
    • Step 3: Run your code
    • Step 4: Debug your code
    • Step 5: Manage the interpreter and packages
  • Set up Jupyter notebooks
    • Install and start JupyterLab
    • Use a notebook
    • Jupyter inside VS Code and PyCharm
  • Troubleshooting common setup problems
  • Optional extras
    • Format your code automatically in VS Code
    • Install PyCharm with JetBrains Toolbox
  • Summary

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.
FeatureVS CodePyCharmJupyter
TypeCode editor with extensionsPython IDEBrowser-based notebook
CostFreeCore features free, Pro features need a subscriptionFree
Speed and sizeLightweight, starts fastHeavier, uses more memoryLight, runs in a browser
Best forGeneral programming, many languagesLarge Python projectsData analysis, learning, experiments
DebuggerYes (Python extension)Yes, built inBasic
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

  1. Go to code.visualstudio.com and download the installer for your operating system.
  2. 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.
  3. macOS: Open the downloaded file and drag Visual Studio Code into your Applications folder. To use the code command in Terminal, open VS Code, press Cmd + Shift + P, and run Shell Command: Install ‘code’ command in PATH.
  4. Linux: Download the .deb (Ubuntu/Debian) or .rpm (Fedora/RHEL) package and install it with your package manager, for example sudo apt install ./code_*.deb.

Step 2: Install the Python extension

VS Code needs Microsoft’s Python extension to understand Python.

  1. Open VS Code and click the Extensions icon in the left sidebar, or press Ctrl + Shift + X (macOS: Cmd + Shift + X).
  2. Search for Python.
  3. 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:

mkdir python_projects
cd python_projects
code .Code language: Python (python)

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.

  1. Open the Command Palette with Ctrl + Shift + P (macOS: Cmd + Shift + P).
  2. Type and select Python: Create Environment.
  3. Choose Venv, then choose the Python version you installed (for example, Python 3.15).
  4. VS Code creates a .venv folder 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:

# Windows
python -m venv .venv

# macOS and Linux
python3 -m venv .venvCode language: Python (python)

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:

name = input("What is your name? ")
print(f"Hello, {name}! VS Code is ready for Python.")Code language: Python (python)

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.py in 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:

scores = [72, 88, 95, 64, 81]
total = 0

for score in scores:
    total = total + score

average = total / len(scores)
print("Average:", average)Code language: Python (python)
  1. Click in the margin to the left of line 5 (total = total + score). A red dot appears. This is a breakpoint.
  2. Press F5 and choose Python Debugger: Current File.
  3. The program pauses at the breakpoint. The Variables panel on the left shows the current values of score, total, and scores.
  4. 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:

ActionWindows / LinuxmacOS
Command PaletteCtrl + Shift + PCmd + Shift + P
Open or close terminalCtrl + `Ctrl + `
Start debuggingF5F5
Run without debuggingCtrl + F5Ctrl + F5
Comment or uncomment lineCtrl + /Cmd + /
Go to definitionF12F12
Rename a variable everywhereF2F2

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

  1. Go to jetbrains.com/pycharm/download and download PyCharm for your operating system.
  2. Windows: Run the .exe installer. On the Installation Options screen, you can check Add “bin” folder to the PATH and Create Associations: .py.
  3. macOS: Open the .dmg file and drag PyCharm into Applications. Choose the Apple Silicon or Intel download to match your Mac.
  4. Linux: Extract the .tar.gz file and run bin/pycharm.sh, or install the Snap package with sudo snap install pycharm --classic.

Step 2: Create a new project

  1. Start PyCharm and click New Project on the Welcome screen.
  2. Select Pure Python (or simply Python, depending on your version).
  3. Enter a project name and location, for example hello_python.
  4. 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.
  5. Leave Create a welcome script checked if you want PyCharm to add a sample main.py file.
  6. 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:

def greet(name):
    return f"Hello, {name}! PyCharm is ready for Python."


print(greet("Jessa"))Code language: Python (python)

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

  1. Click in the gutter next to the line return f"Hello, ..." to set a breakpoint (a red dot).
  2. Right-click in the editor and choose Debug ‘hello’, or click the bug icon in the toolbar.
  3. The program pauses at the breakpoint. The Debug tool window shows the value of name under Threads & Variables.
  4. 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_name in PyCharm’s Terminal tool window. It activates the project’s virtual environment automatically.
  • If PyCharm underlines an import in 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:

# 1. Create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS and Linux
source .venv/bin/activate

# 2. Install JupyterLab
python -m pip install jupyterlab

# 3. Start it
jupyter labCode language: Python (python)

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:

python -m pip install notebook
jupyter notebookCode language: Python (python)

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:

scores = [72, 88, 95, 64, 81]
average = sum(scores) / len(scores)
print(f"Average: {average}")Code language: Python (python)
Average: 80.0

Cell 2:

# Variables from earlier cells are still available
sorted(scores, reverse=True)[:3]Code language: Python (python)
[95, 88, 81]

Two things make notebooks different from running a .py file:

  • State is shared between cells. scores was 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

  1. Install the Jupyter extension by Microsoft from the Extensions view.
  2. Run Create: New Jupyter Notebook from the Command Palette, or create a file ending in .ipynb.
  3. Click Select Kernel in the top-right corner and pick your project’s .venv environment.
  4. 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:

import sys

print(sys.executable)Code language: Python (python)

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:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserCode language: Python (python)

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.

python -m pip install ipykernel
python -m ipykernel install --user --name my_projectCode language: Python (python)

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:

{
    "files.autoSave": "afterDelay",
    "editor.formatOnSave": true,
    "[python]": {
        "editor.defaultFormatter": "charliermarsh.ruff"
    }
}Code language: Python (python)

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 jupyterlab and start with jupyter 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 .ipynb notebooks directly. The environment needs the ipykernel package.
  • Most setup problems come from the editor using a different Python environment from the one you installed packages into. Check sys.executable and the selected interpreter.

Next step: Your editor is ready. Now write your first Python program: Hello World.

Filed Under: Python, Python Basics

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises
Java Exercises
C# Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Leave a Reply Cancel reply

your email address will NOT be published. all comments are moderated according to our comment policy.

Use <pre> tag for posting code. E.g. <pre> Your entire code </pre>

In: Python Python Basics
TweetF  sharein  shareP  Pin

  Python Tutorials

  • Get Started with Python
  • Python Statements
  • Python Comments
  • Python Keywords
  • Python Variables
  • Python Operators
  • Python Data Types
  • Python Casting
  • Python Control Flow statements
  • Python For Loop
  • Python While Loop
  • Python Break and Continue
  • Python Nested Loops
  • Python Input and Output
  • Python range function
  • Check user input is String or Number
  • Accept List as a input from user
  • Python Numbers
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python Functions
  • Python Modules
  • Python isinstance()
  • Python OOP
  • Python Inheritance
  • Python Exceptions
  • Python Exercise for Beginners
  • Python Quiz for Beginners

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

  • Python Basics
  • Python Exercises
  • Python Quizzes
  • Python File Handling
  • Python Date and Time
  • Python OOP
  • Python Random
  • Python Regex
  • Python Pandas
  • Python Databases
  • Python MySQL
  • Python PostgreSQL
  • Python SQLite
  • Python JSON

About PYnative

PYnative.com is a platform built to help developers learn by doing. Solve coding exercises, take MCQs, and run code directly in built-in online compilers.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises
  • Java Exercises
  • C# Exercises

MCQ Quizzes

  • Python MCQs
  • Java MCQs
  • C++ MCQs

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com