鱼C论坛

 找回密码
 立即注册
查看: 2227|回复: 2

[已解决]matplotlib使用时遇到问题

[复制链接]
发表于 2018-3-1 09:59:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import matplotlib.pyplot as plt
  2. squares = [1, 4, 9, 16, 25]
  3. plt.plot(squares)
  4. plt.show()
复制代码

代码如上,run moudle时报错,内容如下:
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\tkagg.py", line 26, in blit
    dataptr, colormode, bboxptr)
_tkinter.TclError: invalid command name "PyAggImagePhoto"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\backend_tkagg.py", line 228, in resize
    self.draw()
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\backend_tkagg.py", line 300, in draw
    tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\tkagg.py", line 34, in blit
    dataptr, colormode, bboxptr)
_tkinter.TclError: error reading data, expected ptr height width
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\tkagg.py", line 26, in blit
    dataptr, colormode, bboxptr)
_tkinter.TclError: error reading data, expected ptr height width

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\tkagg.py", line 26, in blit
    dataptr, colormode, bboxptr)
_tkinter.TclError: error reading data, expected ptr height width

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "C:\Python34\lib\tkinter\__init__.py", line 582, in callit
    func(*args)
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\backend_tkagg.py", line 320, in idle_draw
    self.draw()
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\backend_tkagg.py", line 300, in draw
    tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File "C:\Users\yiming\AppData\Roaming\Python\Python34\site-packages\matplotlib\backends\tkagg.py", line 34, in blit
    dataptr, colormode, bboxptr)
_tkinter.TclError: error reading data, expected ptr height width

图片也显示了,但是没有曲线,是空白的,哪位鱼油能帮忙看看是什么原因?matplotlib我已经安装成功了的,导入模块什么的也是正常的。
最佳答案
2018-3-1 10:05:10
实测安装好matplotlib后,代码没有问题
我怀疑你安装的matplotlib版本和你的python版本不匹配
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-3-1 10:05:10 | 显示全部楼层    本楼为最佳答案   
实测安装好matplotlib后,代码没有问题
我怀疑你安装的matplotlib版本和你的python版本不匹配
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-3-1 11:09:06 | 显示全部楼层
BngThea 发表于 2018-3-1 10:05
实测安装好matplotlib后,代码没有问题
我怀疑你安装的matplotlib版本和你的python版本不匹配



我电脑是64位操作系统啊,安装的matplotlib也是对应版本的,matplotlib-2.2.0rc1-cp34-none-win_amd64.whl,python版本是34,应该没问题才对,那我再检查检查吧,谢谢了。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-19 14:59

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表