'Import Error: cannot import name 'ft2font' from partially initialized module 'matplotlib'

import matplotlib.pyplot as plt

output

ImportError                               Traceback (most recent call last)
<ipython-input-7-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt

~\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py in <module>
    172 
    173 
--> 174 _check_versions()
    175 
    176 

~\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py in _check_versions()
    157     # Quickfix to ensure Microsoft Visual C++ redistributable
    158     # DLLs are loaded before importing kiwisolver
--> 159     from . import ft2font
    160 
    161     for modname, minver in [

ImportError: cannot import name 'ft2font' from partially initialized module 'matplotlib' (most likely due to a circular import) (C:\Users\p****\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py)



Solution 1:[1]

As you are on a windows machine, there is a possible duplicate. Navigate by clicking here.

This could be an issue regarding matplotlib. A force reinstall over pip would solve the issue.

pip install matplotlib --force-reinstall

If you are working on Anaconda, launch Anaconda as Administrator,

conda install freetype --force-reinstall

This solved the same issue for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1