0

First off, I should mention that I patched the matplotlib's fontmanager.py according to the 'Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC)'. I am using Windows 10 and python3.5.2 and was just running super simple plotting using matplotlib in ipython notebook. The code is presented below.

import numpy as np
import matplotlib.pyplot as plt

num_points = 1000
vectors_set = []
for i in range(num_points):
    x1 = np.random.normal(0.0, 0.55)
    y1 = x1*0.1 + 0.3 + np.random.normal(0.0, 0.03)
    vectors_set.append([x1, y1])

x_data =[v[0] for v in vectors_set]
y_data =[v[1] for v in vectors_set]

plt.plot(x_data, y_data)
plt.show()

But I still get the same error. Here's my error messages.

c:\python35\lib\site-packages\matplotlib\font_manager.py in findSystemFonts(fontpaths, fontext)
    323             fontpaths = [fontdir]
    324             # now get all installed fonts directly...
--> 325             for f in win32InstalledFonts(fontdir):
    326                 base, ext = os.path.splitext(f)
    327                 if len(ext)>1 and ext[1:].lower() in fontexts:

c:\python35\lib\site-packages\matplotlib\font_manager.py in win32InstalledFonts(directory, fontext)
    239                     if not os.path.dirname(direc):
    240                         direc = os.path.join(directory, direc)
--> 241                     direc = direc.split('\0', 1)[0]
    242                     if os.path.splitext(direc)[1][1:] in fontext:
    243                         items[direc] = 1

c:\python35\lib\ntpath.py in abspath(path)
    533         if path: # Empty path must return current working directory.
    534             try:
--> 535                 path = _getfullpathname(path)
    536             except OSError:
    537                 pass # Bad path - return unchanged.

ValueError: _getfullpathname: embedded null character

At line 241, it says:

direc = direc.split('\0', 1)[0]

like @simonzack suggested.

Community
  • 1
  • 1
  • That's an odd traceback. Try deleting the "matplotlib\\_\_pycache\_\_" directory to recompile. Manually doing this shouldn't be necessary if the timestamp on font_manager.py has changed and you have write access to the directory. – Eryk Sun Feb 19 '17 at 14:19
  • This problem with null-terminated registry strings should be fixed in 3.6.1. See [issue 25778](http://bugs.python.org/issue25778). – Eryk Sun Feb 19 '17 at 14:20
  • You mean python 3.6.1? Actually I'm using python 3.5.2. – Kang Daniel Feb 20 '17 at 01:21
  • Wow, but anyway deleting "matplotlib\_pycache__" somehow did the trick. It works now. Thank you! Actually when I ran the same code on windows command prompt I ran well but the problem was ipython notebook. (Thou deleting the cache fixed it anyway) What do you think the problem was? Cuz' this is not the first time that only ipython has some problems when running on console directly doesn't have any problem – Kang Daniel Feb 20 '17 at 01:22

0 Answers0