VS Code

How to Install Matplotlib in VSCode

How to Install Matplotlib in VSCode

You wrote the code. Now you need to see the data.

Learning how to install matplotlib in VSCode takes about 3 minutes and unlocks Python’s most popular data visualization library right inside your code editor.

No more switching between windows. No more terminal confusion.

Matplotlib lets you create charts, graphs, and scientific plots directly in your Python scripts. VSCode’s integrated terminal and Python extension make the installation process straightforward.

This guide walks you through verifying your Python setup, running the pip install command, selecting the correct interpreter, and testing that everything works.

Five steps. Working plots by the end.

How to Install Matplotlib in VSCode

maxresdefault How to Install Matplotlib in VSCode

Installing matplotlib in VSCode is the process of adding Python’s data visualization library to your development environment using the pip package manager.

You need this when building charts, graphs, or scientific plots inside Visual Studio Code.

This guide covers 5 steps requiring 3-5 minutes and basic familiarity with VSCode.

Prerequisites

Before running the pip install command, confirm these requirements:

  • Python 3.8 or later installed on your system
  • VSCode version 1.70+ with the Python extension (ms-python.python)
  • pip package manager (bundled with Python 3.4+)
  • Internet connection for PyPI package download
  • Terminal access within the integrated development environment

Missing the Python extension? Open the extension marketplace in VSCode and search for “Python” by Microsoft.

Step One: How Do You Verify Python Is Installed in VSCode?

Open VSCode and launch the integrated terminal using Ctrl+ (Windows/Linux) or Cmd+ (macOS), then type python --version to confirm your Python interpreter is accessible.

The terminal should display something like “Python 3.12.0”.

No version number? Python isn’t in your PATH or isn’t installed. You can learn how to run Python in VSCode for proper setup.

Action

  1. View > Terminal or press Ctrl+
  2. Type: python –version
  3. Expected result: Python version number displayed

Purpose

Confirms the Python interpreter works before matplotlib installation begins.

Step Two: How Do You Open the Integrated Terminal in VSCode?

The integrated terminal provides command line access directly inside your code editor.

You need it to run pip commands without switching windows.

Check out the full guide on how to open terminal in VSCode if you want more options.

Action

  1. Menu path: Terminal > New Terminal
  2. Keyboard shortcut: Ctrl+ (Windows/Linux) or Cmd+ (macOS)
  3. Expected result: Terminal panel opens at the bottom of the VSCode window

Purpose

Keeps your workflow inside VSCode. No need for external Command Prompt or PowerShell windows.

Step Three: How Do You Install Matplotlib Using pip?

Run pip install matplotlib in the terminal to download the package from PyPI (Python Package Index).

This also installs NumPy as a dependency.

On some systems, use pip3 install matplotlib instead if you have both Python 2 and Python 3.

Action

  1. In terminal, type: pip install matplotlib
  2. Alternative for Python 3: pip3 install matplotlib
  3. Expected result: “Successfully installed matplotlib-X.X.X” message

If pip isn’t recognized, you may need to install pip on VSCode first.

Purpose

Downloads matplotlib and its dependencies from PyPI to your Python environment.

Common Output

You’ll see download progress bars, then a confirmation showing the matplotlib version and any installed dependencies like NumPy, Pillow, and pyparsing.

Step Four: How Do You Select the Correct Python Interpreter?

VSCode needs to know which Python environment contains your matplotlib installation.

Open the Command Palette with Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS), then search for “Python: Select Interpreter”.

Choose the interpreter where you ran pip install. For detailed steps, see how to change Python interpreter in VSCode.

Action

  1. Press Ctrl+Shift+P to open Command Palette
  2. Type: Python: Select Interpreter
  3. Select the Python path where matplotlib was installed

Purpose

Connects VSCode to the correct Python environment. Wrong interpreter = “module not found” errors.

Step Five: How Do You Verify Matplotlib Installation?

Create a test file and run an import statement to confirm matplotlib works.

No errors means success.

Action

  1. Create new file: test_matplotlib.py
  2. Add code: import matplotlib.pyplot as plt
  3. Run with F5 or Run > Run Without Debugging
  4. Expected result: No import errors

Purpose

Confirms matplotlib.pyplot is accessible and functional in your workspace.

Verification

Run this code snippet to generate a basic plot:

` import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4], [1, 4, 2, 3]) plt.title(‘Test Plot’) plt.show() `

A plot window should appear. If you’re using Jupyter notebook integration, the chart renders inline.

Working plot = successful installation.

Troubleshooting

Issue: “pip is not recognized as a command”

Add Python Scripts folder to your PATH environment variable, or use the full path to pip.exe.

Windows example: C:Python312Scriptspip.exe install matplotlib

Issue: “No module named matplotlib”

Wrong interpreter selected. Open Command Palette, run “Python: Select Interpreter”, choose the environment where you installed matplotlib.

Verify with pip show matplotlib in the same terminal.

Issue: ModuleNotFoundError After Installation

Installed in global Python but using a virtual environment? Activate your venv first.

Learn how to activate venv in VSCode, then reinstall matplotlib inside it.

Issue: Permission Denied During Installation

Use pip install –user matplotlib or run terminal as administrator.

The –user flag installs to your user directory, avoiding system-level permission issues.

Alternative Methods

Method A: pip in Terminal (Current Guide)

  • Time: 2-3 minutes
  • Best for: Quick setup in global Python environment

Method B: Virtual Environment Installation

  • Time: 5-7 minutes
  • Best for: Project isolation, dependency management, avoiding conflicts

Create venv with python -m venv myenv, activate it, then run pip install matplotlib.

When done working, you can exit venv in VSCode to return to global Python.

Method C: Conda Installation

  • Time: 3-4 minutes
  • Best for: Anaconda or Miniconda users

Run conda install matplotlib in the Anaconda Prompt or VSCode terminal with conda environment active.

Related Processes

FAQ on How To Install Matplotlib In VSCode

How do I install matplotlib in VSCode?

Open the integrated terminal with Ctrl+ and run pip install matplotlib. The package downloads from PyPI automatically. Select the correct Python interpreter afterward to ensure VSCode recognizes the installation.

Why is matplotlib not working in VSCode?

Wrong Python interpreter selected. Open Command Palette (Ctrl+Shift+P), search “Python: Select Interpreter”, and choose the environment where matplotlib was installed. Run pip show matplotlib to verify the installation path.

What Python version do I need for matplotlib?

Matplotlib requires Python 3.8 or later. Check your version with python --version in the terminal. Older Python versions may work but lack support for recent matplotlib features and security updates.

How do I check if matplotlib is installed?

Run pip show matplotlib in VSCode’s terminal. This displays the package version, location, and dependencies. Alternatively, type import matplotlib in a Python file. No errors means successful installation.

Can I install matplotlib in a virtual environment?

Yes. Create a venv with python -m venv myenv, activate it, then run pip install matplotlib. Virtual environments keep project dependencies isolated. VSCode detects venvs automatically in your codebase folder.

What is the pip command to install matplotlib?

Use pip install matplotlib for standard installation. For Python 3 specifically, use pip3 install matplotlib. Add --user flag if you encounter permission errors on Linux or macOS systems.

How do I fix “No module named matplotlib” error?

Select the correct interpreter in VSCode where matplotlib exists. The module not found error occurs when VSCode points to a different Python environment. Reinstall matplotlib in your active environment if needed.

Does matplotlib work with Jupyter in VSCode?

Yes. Install the Jupyter extension from the marketplace. Matplotlib plots render inline inside notebook cells. Use %matplotlib inline magic command for embedded charts without separate plot windows appearing.

How do I update matplotlib in VSCode?

Run pip install --upgrade matplotlib in the integrated terminal. This fetches the latest package version from PyPI. Check current version first with pip show matplotlib to confirm the update worked.

What dependencies does matplotlib install?

Matplotlib automatically installs NumPy, Pillow, pyparsing, cycler, kiwisolver, and python-dateutil. These dependencies handle numerical operations, image processing, and date formatting. The pip package manager resolves all requirements during installation.

Conclusion

You now know how to install matplotlib in VSCode and can start building visualizations immediately.

The process comes down to running a single pip command and selecting the right interpreter.

Virtual environments keep your projects clean. Use them for anything beyond quick experiments.

If plots don’t render, check your backend configuration or try adding plt.show()` at the end of your script.

Matplotlib pairs well with NumPy, pandas, and SciPy for scientific computing workflows.

VSCode’s Python extension and Pylance provide code completion for matplotlib.pyplot methods, making script execution faster.

Add matplotlib to your requirements.txt file for reproducible project setups.

Now go plot something.

50218a090dd169a5399b03ee399b27df17d94bb940d98ae3f8daff6c978743c5?s=250&d=mm&r=g How to Install Matplotlib in VSCode
Latest posts by Bogdan Sandu (see all)

Stay sharp. Ship better code.

Every week: one curated article, one tool worth knowing, one tip you can use tomorrow. No noise, no padding.