0

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?

asked Mar 19, 2020 at 1:42

2 Answers 2

0

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

answered Mar 20, 2020 at 19:26

1 Comment

Be very careful with that, especially if you are mixing conda-forge packages with those from the regular Anaconda channels. There's no guarantee that conda-forge packages will be compatible with mainline packages, and the conda-forge maintainers recommend installing conda-forge packages in a separate environment.
0

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.

answered Mar 31, 2020 at 10:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.