Matplotlib TypeError when importing matplotlib.pyplot

I just used conda to upgrade my Anaconda installation, and Matplotlib switched from v1.4.0 to v1.4.2. However, now all my Python jobs that use Matplotlib.pyplot throw exceptions.

Even a simple command:

import matplotlib.pyplot as plt 

throws a TypeError exception by saying:

cannot return std :: string from a Unicode object

Tracking tells me that the exception occurs in the font_manager.py file, here:

 try: font = ft2font.FT2Font(fpath) except RuntimeError: verbose.report("Could not open font file %s" % fpath) continue except UnicodeError: verbose.report("Cannot handle unicode filenames") continue 

especially on the line font = ft2font.FT2Font(fpath) .

I tried to return to Matplotlib v1.4.0, but this did not fix the problem.

Then I edited font_manager.py to add a generic exception case:

 except: verbose.report("Some stupid error occurred") continue 

in the hope that he would temporarily circumvent the problem, which he did, but this error or something very similar to it happened later. So, I removed the exception, but the error still occurs at a later point in the code (therefore, if I run import matplotlib.pyplot as plt , it works, but the execution of other commands may fail).

I use Matplotlib to create / update hundreds of charts during the day, and now everything is broken.

Please, help! Thanks!

+5
source share
1 answer

It seems that uninstalling Anaconda and reinstalling the new version fixes the problem as mentioned in @pbreach, so close this question.

+1
source

Source: https://habr.com/ru/post/1210490/


All Articles