1
votes

When I plot with datalab, I keep getting the same warning about font. It actually renders the plot fine, but I comes up every time. How can I get rid of it?

df.plot();

/usr/local/envs/py3env/lib/python3.5/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext]))

2

2 Answers

1
votes

VictorGGI solution did not work for me as the file always returned to its previous state (maybe reset on datalab restart ?). Anyway, a simpler fix to this issue would be to hide warnings with :

import warnings
warnings.filterwarnings("ignore")
0
votes

You can access the docker container where Datalab is running using the steps in here.

docker ps
docker exec -it <your-container-id> bash

Access the directory where the font_manager.py file is located:

cd /usr/local/envs/py3env/lib/python3.5/site-packages/matplotlib/

Edit the font_manager.py file and comment out lines 1227,1228,1229

  #warnings.warn('findfont: Could not match %s. Returning %s.' %
  #                        (prop, self.defaultFont[fontext]),
  #                        UserWarning)

(if you cannot use vim/vi or whatever text editor you can make use of gsutil command and upload the file to a bucket, edit it and download it again)