No module named '_tkinter' configured

做~自己de王妃 提交于 2021-01-28 06:53:26

问题


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.

  1. 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.
  2. Look for Tk in your python module library and reinstall it.
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!