0

I have installed tkinter on my Raspberry Pi that is running Raspbian. It is installed for both python2 and python3. However while importing it in python3, it shows me an error:

>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'

While importing 'Tkinter' for python2, it works well. But for python3, it doesn't. I've tried all the solutions in other answers related to my problem on StackExchange. I have Python 3.5.1 and Python 2.7.13.

Thanks for your help.

New contributor
Sukanya Kamboj is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • tkinter is a built in part of python, so if you have python installed correctly it should work. How did you install python3? I ask because I see yours is installed in /usr/local/lib and if installed with apt, it installs to /usr/lib. Also your version of python is older, so what version of raspbian do you have? It may be as simple as updating your packages with sudo apt update and sudo apt upgrade – T. M. Feb 14 at 10:31
  • Thank you for your help. I formatted my SD Card, did a fresh install of the OS and the problem was resolved. Both python versions were already installed, turns out that I missed it at first and manually installed python 3.5.1. That could have caused it. – Sukanya Kamboj Feb 14 at 14:55

Your Answer

Sukanya Kamboj is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.