使用tkagg后端时出错

时间:2016-01-04 01:16:09

标签: python-3.x matplotlib python-3.5

我使用以下设置:

function compareToValue($checks, $comparer) {
  $flag = false;
  foreach ($checks as $check) 
    if (!empty($check) && $check[0] === $comparer)
       $flag = true;
  return $flag;
}

$fields = array(
   get_post_meta($page_id, $subfield1),
   get_post_meta($page_id, $subfield2),
   get_post_meta($page_id, $subfield8)
);

if(!compareToValue($fields, 'your unique string')) {
   // ... run code if no perfect match
}; 

我已将Python 3.5.2 + Matplotlib 1.5.x (Raspberry Pi) 添加到我的rc文件中。

如果我运行backend :tkagg,则返回get_backend()

但是,当我尝试按如下方式导入"tkagg"时:

matplotlib

我收到以下追溯:

 Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
 [GCC 4.9.1] on linux
 Type "copyright", "credits" or "license()" for more information.

 >>> import matplotlib as mpl
 >>> mpl.use('tkagg')
 >>> import matplotlib.pyplot as plt

为什么没有正确导入 Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> import matplotlib.pyplot as plt File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/pyplot.py", line 114, in <module> backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/__init__.py", line 32, in pylab_setup globals(),locals(),[backend_name],0) File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/backend_tkagg.py", line 13, in <module> import matplotlib.backends.tkagg as tkagg File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/tkagg.py", line 9, in <module> from matplotlib.backends import _tkagg ImportError: cannot import name '_tkagg'

1 个答案:

答案 0 :(得分:0)

我基本上按照这篇文章中的说明操作: tkagg backend problems

然后使用git获取源代码: sudo git clone git://github.com/matplotlib/matplotlib.git

然后使用Python3.4进行构建/安装: sudo python3.4 setup.py install