Enthought - matplotlib (problems with plot () function)

I am trying to use matplotlib in Canopy Express. Even simple code does not start ...

NOTE: the system does not recognize the plot(x) function. There seems to be something with ASCII X Unicode. My computer uses Unicode English (US).

From the console we have:

  C:\Users\dafonseca\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\font_manager.py in createFontList(fontfiles, fontext) 582 continue 583 try: --> 584 prop = ttfFontProperty(font) 585 except KeyError: 586 continue C:\Users\dafonseca\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\font_manager.py in ttfFontProperty(font) 396 sfnt2 = '' 397 if sfnt4: --> 398 sfnt4 = sfnt4.decode('ascii').lower() 399 else: 400 sfnt4 = '' UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 0: ordinal not in range(128)' import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10) line, = plt.plot(x, np.sin(x), '--', linewidth=2) dashes = [10, 5, 100, 5] # 10 points on, 5 off, 100 on, 5 off line.set_dashes(dashes) plt.show() 
+4
source share
1 answer

This is a known issue in matplotlib 1.3.0, which refers to the presence of a non-ASCII character in one of your font names (possibly a Æ character).

You can find or remove the intruder font (best idea) or try to fix your installation by doing the following:

Open the following in a text editor:

\Users\dafonseca\AppData\Local\Enthought\Canopy\User\lib\site- packages\matplotlib\font_manager.py

Search for sfnt4 = sfnt4.decode('ascii').lower()

And replace with sfnt4 = sfnt4.decode('ascii', 'ignore').lower()

Please note that this error will not exist in the next version of matplotlib.

+6
source

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


All Articles