'No module named '_tkinter' configured
ModuleNotFoundError: No module named '_tkinter'
I want to import turtle in Python 3.7
Traceback (most recent call last): File "my.py", line 1, in from turtle import * File "/usr/local/lib/python3.7/turtle.py", line 107, in import tkinter as TK File "/usr/local/lib/python3.7/tkinter/init.py", line 36, in import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter'
Solution 1:[1]
When building python from source, if the Tk
development files are missing,
the build ends with
The necessary bits to build these optional modules were not found:
_tkinter
The development files can be installed from the distribution packager. for instance, in openSUSE Leap-15:
sudo zypper install tk-devel
Solution 2:[2]
The IDE tells you that your python is not confingured for Tk (tkinter), which is your problem. While I am not certain on how to fix this becuase I never use turtle or Tk, I have a few ideas.
- I am using python 3.7 and importing both turtle and Tk works just fine for me, so I definitely recommend updating to 3.7.
- Look for Tk in your python module library and reinstall it.
- Just find out how to confingure Tk with python 3.2 if updating doesn't work.
I hope I helped!
Solution 3:[3]
As @ederag said, I have installed Python3.7 and tkinter in opensuse.
sudo zypper refresh
sudo zypper update
sudo zypper in zlib-devel bzip2 libbz2-devel libffi-devel libopenssl-devel readline-devel sqlite3 sqlite3-devel xz xz-devel gcc tk-devel tcl-devel
cd ~/Downloads
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar xf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure
make
sudo make altinstall
sudo ln -s /usr/local/lib64/python3.7/lib-dynload /usr/local/lib/python3.7/lib-dynload
Solution 4:[4]
if you are using linux go to terminal and type sudo apt-get install python3-tk
if you are using windows go to command prompt and type cd C:/Program Files/Python/python37/Scripts
press enter then type pip install tkinter
hope it helped!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ederag |
Solution 2 | |
Solution 3 | jatorna |
Solution 4 | Anthony Arnzen |