Keng
Keng

Reputation: 61

How to fix this ImportError: from . import ft2font

I was installing Matplotlib to use on Jupyter Notebook on MacOS, M1 chip. The statement import matplotlib.pyplot as plt produces the error result:

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

~/miniforge3/envs/tfenv/lib/python3.9/site-packages/matplotlib/__init__.py in <module>
    155 
    156 
--> 157 _check_versions()
    158 
    159 

~/miniforge3/envs/tfenv/lib/python3.9/site-packages/matplotlib/__init__.py in _check_versions()
    140     # Quickfix to ensure Microsoft Visual C++ redistributable
    141     # DLLs are loaded before importing kiwisolver
--> 142     from . import ft2font
    143 
    144     for modname, minver in [

ImportError: dlopen(/Users/watcharinsarachai/miniforge3/envs/tfenv/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so, 2): Symbol not found: _FT_Done_Face
  Referenced from: /Users/watcharinsarachai/miniforge3/envs/tfenv/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so
  Expected in: flat namespace
 in /Users/watcharinsarachai/miniforge3/envs/tfenv/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so

Any idea what to do? I'm using MacOS 11.4, M1 chip and python 3.9.5 installed by homebrew.

Upvotes: 0

Views: 1900

Answers (1)

Keng
Keng

Reputation: 61

Problem solved. I forgot to tell you that I have installed python using conda environment as suggest from Apple and I have installed the matplotlib using:

pip install matplotlib

To fix this I have removed matplotlib using:

pip uninstall matplotlib

then reinstall it with:

conda install -c conda-forge matplotlilb

Upvotes: 2

Related Questions