pythonpython-2.7tkinterrobotframeworkplone

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


I trying to debug a Robot Framework test on my Plone add-on package by using the following as I found in the documentation:

*** Settings ***

Resource  plone/app/robotframework/keywords.robot

*** Test Cases ***

Pause tests with included Pause-keyword
   Pause

When the test is run the following error is shown:

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

I already have Tkinter installed in my system:

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

How can I fix this?


Solution

  • I had to install the tk-dev package (in my case by using sudo apt-get install tk-dev) and recompile the Python I was using on my virtualenv.

    I found the answer here: https://stackoverflow.com/a/5459492/644075