I have created and added a new Conda environment to my Jupyter notebook. I had to install matplotlib to this environment again. Now when I import matplotlib using this new Conda environment within Jupyter, I get this error:
ImportError Traceback (most recent call last) in 1 import numpy as np 2 import pandas as pd ----> 3 import matplotlib.pyplot as plt 4 get_ipython().run_line_magic('matplotlib', 'inline') 5 import matplotlib as mpl
~\AppData\Roaming\Python\Python38\site-packages\matplotlib__init__.py in 203 204 --> 205 _check_versions() 206 207
~\AppData\Roaming\Python\Python38\site-packages\matplotlib__init__.py in _check_versions() 188 # Quickfix to ensure Microsoft Visual C++ redistributable 189 # DLLs are loaded before importing kiwisolver --> 190 from . import ft2font 191 192 for modname, minver in [
ImportError: cannot import name 'ft2font' from partially initialized module 'matplotlib' (most likely due to a circular import) (C:\Users\alber\AppData\Roaming\Python\Python38\site-packages\matplotlib__init__.py)
I'm pretty sure this has something to do with the 'circular import' statement, and the program trying to read the other version of matplotlib? But I'm not sure how to proceed. I've tried searching for answers for my specific issue and found no luck. What is the best way to get this environment working in Jupyter?
2 Answers 2
EDIT: I fixed the issue by installing everything using pip from a clean environment as per the conversation here: https://github.com/ipython/ipython/issues/11821
For me runnning
conda update -c conda-forge matplotlib
seems to have worked. Found solution in discussion here: https://github.com/conda/conda/issues/9493
1 Comment
I encountered this when following a tutorial (https://realpython.com/pandas-python-explore-dataset/) which only called '%matplotlib inline' after much earlier work. As I had other notebooks with matplotlib working and "python -c 'import matplotlib'" worked for the environment, I determined that the key difference for this notebook was where '%matplotlib inline' was being executed.
So, I moved '%matplotlib inline' to the first cell, restarted the kernel and everything working just fine.