'how to fix the error that ModuleNotFoundError: No module named '_tkinter'
I connected to the remote server (google cloud VM instance - Centos7) with PyCharm from my Windows computer and wanted to execute the code using the remote computer's python3.8.8 via PyCharm. However, I got the error that says
File "/usr/local/lib/python3.8/tkinter/init.py", line 36, in
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I tried to do some different pip installs (pip install python3-tkinter, pip install python3-tk, pip install python3.8-tkinter, etc.) and output of
"pip install python3-tkinter" is
Package python3-tkinter-3.6.8-18.el7.x86_64 already installed and latest version Nothing to do.
Is this tkinter for python3.6?
How can I fix this error?
Solution 1:[1]
The whole link to the thread is here:
How to pip or easy_install tkinter on Windows
but in particular, where is tkinter being run from ? your PC or the remote PC, because either way, it needs to be installed on the machine that it will be running (or called) from.
The Tkinter library is built-in with every Python installation. And since you are on Windows, I believe you installed Python through the binaries on their website?
If so, Then most probably you are typing the command wrong. It should be:
import Tkinter as tk
Note the capital T at the beginning of Tkinter.
For Python 3,
import tkinter as tk
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 | D.L |
