Issue
Currently using Ubuntu 20.04 LTS with python3.8.5. Its my first time using ubuntu with absolutely no previous knowledge of terminal.SO,would love to have a detailed answer if possible. Below is terminal output when i try importing tkinter in python3.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
>>>
I have reinstalled python3 and tkinter using sudo apt.But still it shows same error. When i run the same command in python IDLE it works without any error. I hope this explains my problem clearly, if any other info. is required pls reply. I also tried running the command >>>from tkinter import *
Solution
Resolved the issue it occurred because the Tkinter was installed for version 3.5 and not for the 3.8 version. For that, I installed the 3.5 version and kept only one version i.e. 3.8, and installed Tkinter again, and it worked! This is just a workaround to make things work, but the more preferred way is to create a venv and then install the particular versions of python and libraries that are needed.
Answered By - Atharva Dhamale
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.