Matplotlib Font Family Not Found

4943
9
11-29-2017 01:02 PM
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I have a script that makes charts. I've been running this script for many months across multiple computers on our network with different versions of Python with no trouble. Today I'm getting this error: 

UserWarning: findfont: Font family [u'Bitstream Vera Sans'] not found. Falling back to DejaVu Sans. 

This is screwing up my charts. I've tried deleting the matplotlib font cache file, and that hasn't helped. That's the only solution I've been able to find online. I haven't added any fonts or changed anything else on the system or in the script. I also did a disk cleanup and restart and it didn't help. This is happening on a Windows 7 machine running Python 2.7.8. 

0 Kudos
9 Replies
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I'm having this issue again after upgrading to Server 10.5.1 and Python 2.7.13

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

A recent issue was reported on GitHub and may be related.  it is worth a read

https://github.com/matplotlib/matplotlib/issues/10201

I have a similar response with ArcGIS PRO

from matplotlib import font_manager

font_manager.findfont('Bitstream Vera Sans')

C:\ArcGISPro\bin\Python\envs\arcgispro-py3\lib\site-packages\matplotlib\font_manager.py:1328: UserWarning: findfont: Font family ['Bitstream Vera Sans'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))

Out[36]: 'C:\\ArcGISPro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\DejaVuSans.ttf'
0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I think this might be a Python path problem somewhere. This script is run locally and it calls on a local Python module to make charts. The same module is called through GP tools on our ArcGIS Server, and those charts look fine. 

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I am going bonkers trying to figure this out. I've deleted the fontList cache, I've installed Bitstream Vera Sans in the matplotlib ttf fonts folder, I've tried to register it. It's still defaulting to Deja Vu and screwing up my charts

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

well that is perhaps not the place where the fonts are being obtained.  search for a known font on you c: drive... maybe you will find more that one locale... install it wherever until you get it figured out

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I looked on another computer with identical scripts that is creating the charts correctly and Vera is installed in the matplotlib mpl-data fonts ttf folder. I have it installed in the same place on the server machine, but I cannot get the script to find it. It's still defaulting to DejaVu Sans.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You indicate 'server' so you aren't using a standalone install of PRO or *Map I presume.

If you don't have multiple installations of python or the python that is being used isn't the one that you think is being used, it will remain an issue. 

You might want to file a tech support ticket... since no other suggestions have helped.

Server stuff can be messy, and I assume you can print from a local installation of python leaving you with little options

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

No. I'm just running ArcPy on the Server machine. The trouble started when I installed Desktop on the ArcGIS Server machine. So we had the 32 and 64 bit versions of Python installed. I uninstalled Desktop and got rid of the previous Python folders (10.5 32bit, 10.3 64 bit) and the problem persists. I've confirmed that Bitstream Vera Sans is installed in the the matplotlib and reportlab site-packages folder, and in the Windows fonts folder. I've tried registering it and deleting the font list cache, and nothing works. I've looked at the fontList JSON file in the .matplotib folder, and Bitstream Vera Sans is listed in the Windows folder along with all the other fonts. 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Saw your other threads... something persists on the server... tech support is my suggestion

0 Kudos