AssertionError: Importing test library 'Dialogs' failed: ImportError: No module named _tkinter

问题描述 投票:0回答:1

我尝试使用我在 documentation 中找到的以下内容在我的 Plone 附加程序包上调试 Robot Framework 测试:

*** 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.

我该如何解决这个问题?

python python-2.7 tkinter robotframework plone
1个回答
0
投票

我必须安装tk-dev包(在我的例子中使用

sudo apt-get install tk-dev
)并重新编译我在我的virtualenv上使用的Python。

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

© www.soinside.com 2019 - 2024. All rights reserved.