Fix Python Matplotlib ImportError: cannot import name ‘_path’ Error: A Beginner Guide – Matplotlib Tutorial

By | November 29, 2019

We have used python matplotlib library to write a python example, however, we encounter an ImportError: cannot import name ‘_path’. In this tutorial, we will introduce how to fix this error.

Why this import error occur?

Look at error message below:

python matplotlib importError - connot import name '_path'

We will find: we have installed python matplotlib, however, this error is reported in path.py.

As to us, this version of python matplotlib is installed in python 3.5, however, the current python version is python 3.6, we have updated python version. So this error occurs.

How to fix matplotlib import error?

The most easiest way is install python matplotlib in python 3.6 again. You can read this tutorial to install matplotlib with anaconda.

Anaconda Install Matplotlib: Fix UnsatisefiableError (A Completed Guide) – Matplotlib Tutorial

We install it again, then this import error is fixed.

2 thoughts on “Fix Python Matplotlib ImportError: cannot import name ‘_path’ Error: A Beginner Guide – Matplotlib Tutorial

  1. saba mushtaq

    how to solve this problem in VScode please help

    Output exceeds the size limit. Open the full output data in a text editor
    —————————————————————————
    ImportError Traceback (most recent call last)
    c:\Users\MC\jupyter notebook\test.ipynb Cell 1 in 3
    1 import pandas as pd
    2 import numpy as np
    —-> 3 import matplotlib.pyplot as mpl

    File ~\AppData\Roaming\Python\Python310\site-packages\matplotlib\pyplot.py:60
    58 from matplotlib import _docstring
    59 from matplotlib.backend_bases import FigureCanvasBase, MouseButton
    —> 60 from matplotlib.figure import Figure, FigureBase, figaspect
    61 from matplotlib.gridspec import GridSpec, SubplotSpec
    62 from matplotlib import rcParams, rcParamsDefault, get_backend, rcParamsOrig

    File ~\AppData\Roaming\Python\Python310\site-packages\matplotlib\figure.py:43
    40 import numpy as np
    42 import matplotlib as mpl
    —> 43 from matplotlib import _blocking_input, backend_bases, _docstring, projections
    44 from matplotlib.artist import (
    45 Artist, allow_rasterization, _finalize_rasterization)
    46 from matplotlib.backend_bases import (
    47 DrawEvent, FigureCanvasBase, NonGuiException, MouseButton, _get_renderer)

    File ~\AppData\Roaming\Python\Python310\site-packages\matplotlib\projections\__init__.py:55
    1 “””

    —> 55 from .. import axes, _docstring
    56 from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
    57 from .polar import PolarAxes

    ImportError: cannot import name ‘axes’ from ‘matplotlib’ (C:\Users\MC\AppData\Roaming\Python\Python310\site-packages\matplotlib\__init__.py)

Leave a Reply