1

I have some problems with tkinter. I want to use it with python 2.7.9 or python 3.4 with DEBIAN but it give me this error in both cases:

Python 3.4.3 (default, Dec  1 2017, 16:25:43) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'

Can you give me some advice to resolve this? I already tried

sudo apt-get install tk-dev

but

erle@erle-brain:~ $  sudo apt-get install tk-dev
[sudo] password for erle: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package tk-dev

I also see that maybe I have to install tcl and tk with this instructions but:

erle@erle-brain:~/build $ sudo apt-get install tcl8.5-dev libi2c-dev autoconf
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package tcl8.5-dev
E: Couldn't find any package by regex 'tcl8.5-dev'

Please help me :( I have to finish a University project and I need Tkinter.

1

In my version of Python 2 the module is called Tkinter (upper case initial T).

In my version of Python 3 the module is called tkinter (lower case initial t). For Python 3 I had to additionally install tk (sudo apt-get install python3-tk).

| improve this answer | |
  • I tried to use Python 2.7 but when I write "import Tkinter" in the terminal the error is the same. and also when I try "sudo apt-get install python3-tk" this is the output: "Package python3-tk is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'python3-tk' has no installation candidate " – flavia13 Dec 1 '17 at 20:02
  • The assumption is you are using Raspbian. Is that correct? You need to fully specify the environment you are using. – joan Dec 1 '17 at 20:16
  • You're right. I'm using Debian Jessie on raspberryPi3. – flavia13 Dec 1 '17 at 20:22
  • Using Debian rather than Raspbian is outside my experience. – joan Dec 1 '17 at 20:31
-1

I solved the problem doing the apt-get update and apt-get upgrade, then doing sudo apt-get install python3-tk and import tkinter on the python terminal works. Now I have another issue but I will open a new topic. Thank you!!!!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.