【问题标题】:Error on importing matplotlib on mac os x在 mac os x 上导入 matplotlib 时出错
【发布时间】:2017-02-28 10:58:13
【问题描述】:
>>> import matplotlib.pyplot as plt
objc[19151]: Class TKApplication is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (0x107aab188) and /Users/rit/anaconda2/envs/mac_gdal/lib/libtk8.5.dylib (0x1117e0e40). One of the two will be used. Which one is undefined.
objc[19151]: Class TKMenu is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (0x107aab1d8) and /Users/rit/anaconda2/envs/mac_gdal/lib/libtk8.5.dylib (0x1117e2020). One of the two will be used. Which one is undefined.
objc[19151]: Class TKContentView is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (0x107aab228) and /Users/rit/anaconda2/envs/mac_gdal/lib/libtk8.5.dylib (0x1117e28a0). One of the two will be used. Which one is undefined.
objc[19151]: Class TKWindow is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (0x107aab278) and /Users/rit/anaconda2/envs/mac_gdal/lib/libtk8.5.dylib (0x1117e2da0). One of the two will be used. Which one is undefined.

导入 matplotlib 时如何解决此错误。我在 Mac Os X (Sierra) 上使用 python 2.7.12

【问题讨论】:

  • 您的tk 安装存在问题,其中tk 是双重安装的。删除其中一个tk 安装,它应该可以工作。
  • 这是在现有的 python 安装上安装 Anaconda 时的常见错误。
  • 感谢@Eli,我在 .matplotlibrc 文件中添加了一个后端 TkAgg,我应该将其更改为其他内容吗?
  • 您是否看过:stackoverflow.com/questions/35593602/… 或类似的问题(谷歌搜索 "Class TKApplication is implemented" 会给出很多类似的结果)?你都尝试了些什么?你试过 Eli 的建议了吗?
  • @Bart 此链接不包含答案! sys.modules 返回了两个 Tk 库,他有很多缺失点,python shell 使用了 default Tkinter 但他从另一个模块调用 Tkinter。 Terminal-Python Idle 是不同的东西。不要使用 python-idle 检查输出与matplotlib 相关的 Tk 目录(在终端上)?永远不要删除重复的模块,可能包含另一个模块(可怕的想法)。 import sys ; remove some duplicate module name on namespace

标签: python matplotlib


【解决方案1】:

如 cmets 中所述,Python 无法决定使用哪个 tk 版本。您是否计划使用 anaconda 环境?如果您没有理由使用 anaconda 版本,我会删除它并使用系统版本。

rm /Users/rit/anaconda2/envs/mac_gdal/lib/libtk8.5.dylib

【讨论】:

  • 随机删除库对我来说听起来是一个非常的坏主意/解决方案
猜你喜欢
  • 1970-01-01
  • 2011-08-08
  • 1970-01-01
  • 2018-09-18
  • 2014-02-12
  • 2012-04-23
  • 2015-12-10
  • 2011-05-16
  • 2015-12-06
相关资源
最近更新 更多