问题
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'
回答1:
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!
回答2:
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
来源:https://stackoverflow.com/questions/54693107/no-module-named-tkinter-configured