AssertionError:导入测试库'Dialogs'失败:ImportError:没有名为_tkinter的模块

时间:2014-12-11 17:57:50

标签: python-2.7 tkinter plone robotframework

我试图在我的Plone附加软件包上调试Robot Framework测试,使用我在documentation中找到的以下内容:

*** Settings ***

Resource  plone/app/robotframework/keywords.robot

*** Test Cases ***

Pause tests with included Pause-keyword
   Pause

运行测试时会显示以下错误:

Failure in test Test Locking Behavior (test_locking_behavior.robot)
Traceback (most recent call last):
  File "/home/hvelarde/.buildout/eggs/unittest2-0.5.1-py2.7.egg/unittest2/case.py", line 340, in run
    testMethod()
  File "/home/hvelarde/.buildout/eggs/robotsuite-1.6.1-py2.7.egg/robotsuite/__init__.py", line 455, in runTest
    assert last_status == 'PASS', last_message
AssertionError: Importing test library 'Dialogs' failed: ImportError: No module named _tkinter
Traceback (most recent call last):
  File "/home/hvelarde/.buildout/eggs/robotframework-2.8.4-py2.7.egg/robot/libraries/Dialogs.py", line 38, in <module>
    from dialogs_py import MessageDialog, PassFailDialog, InputDialog, SelectionDialog
  File "/home/hvelarde/.buildout/eggs/robotframework-2.8.4-py2.7.egg/robot/libraries/dialogs_py.py", line 17, in <module>
    from Tkinter import (Tk, Toplevel, Frame, Listbox, Label, Button, Entry,
  File "/home/hvelarde/buildout.python/parts/opt/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
PYTHONPATH:
  /home/hvelarde/.buildout/eggs/robotframework-2.8.4-py2.7.egg/robot/libraries
  /home/hvelarde/.buildout/eggs/robotframework-2.8.4-py2.7.egg
  /home/hvelarde/.buildout/eggs/Plone-4.3.4-py2.7.egg
  /home/hvelarde/.buildout/eggs/Products.ATContentTypes-2.1.14-py2.7.egg/Products/ATContentTypes/thirdparty
  /home/hvelarde/.buildout/eggs/plone.app.upgrade-1.3.7-py2.7.egg
  /home/hvelarde/collective/nitf/src
    [ Message content over the limit has been removed. ]
  /home/hvelarde/collective/nitf/bin
  /home/hvelarde/buildout.python/python-2.7/lib/python27.zip
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7/plat-linux2
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7/lib-tk
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7/lib-old
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7/lib-dynload
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/plat-linux2
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/lib-tk
  /home/hvelarde/buildout.python/python-2.7/lib/python2.7/site-packages
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/site-packages/setuptools-2.2-py2.7.egg
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/site-packages/Pillow-2.6.0-py2.7-linux-x86_64.egg
  /home/hvelarde/buildout.python/parts/opt/lib/python2.7/site-packages
  .
  /home/hvelarde/collective/nitf/parts/test

我已经在我的系统中安装了Tkinter:

# sudo apt-get install python-tk
Lendo listas de pacotes... Pronto
Construindo árvore de dependências       
Lendo informação de estado... Pronto
python-tk já é a versão mais nova.
python-tk configurado para instalar manualmente.
Os seguintes pacotes foram automaticamente instalados e não são mais necessários:
  linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
  linux-image-3.13.0-39-generic linux-image-extra-3.13.0-39-generic
Use 'apt-get autoremove' to remove them.
0 pacotes atualizados, 0 pacotes novos instalados, 0 a serem removidos e 13 não atualizados.

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我必须安装 tk-dev 包(在我的情况下使用sudo apt-get install tk-dev)并重新编译我在virtualenv上使用的Python。

我在这里找到答案:https://stackoverflow.com/a/5459492/644075