1. 程式人生 > >matplotlib使用savefig遇到錯誤 integer argument expected got float

matplotlib使用savefig遇到錯誤 integer argument expected got float

解決方案:

pip3 install --upgrade pillow

錯誤程式碼:

 File "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py", line 1814, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/backend_qt5agg.py", line 172, in print_figure
    super(FigureCanvasQTAggBase, self).print_figure(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/matplotlib/backend_bases.py"
, line 2259, in print_figure **kwargs) File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/backend_agg.py", line 584, in print_jpg return background.save(filename_or_obj, format='jpeg', **options) File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1675, in save save_handler(self, fp, filename) File "/usr/lib/python3/dist-packages/PIL/JpegImagePlugin.py"
, line 708, in _save ImageFile._save(im, fp, [("jpeg", (0, 0)+im.size, 0, rawmode)], bufsize) File "/usr/lib/python3/dist-packages/PIL/ImageFile.py", line 480, in _save e = Image._getencoder(im.mode, e, a, im.encoderconfig) File "/usr/lib/python3/dist-packages/PIL/Image.py", line 431, in _getencoder return
encoder(mode, *args + extra) TypeError: integer argument expected, got float