I am stuck with this issue since last two days and I have tried every possible solution on the stack and github. It will be really great if someone can recommend.
I am working with python 2.7 in a virtual environment on CentOS Linux release 7.3.1611.
I am running a script that uses matplotlib.pyplot and on run gives this error
import matplotlib.pyplot as plt File "/usr/local/packages/Python-2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module> import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter
I tried to install tkinter using -
pip install tkinter and it gave this error Could not find a version that satisfies the requirement tkinter (from versions: ) No matching distribution found for tkinter
then I even installed -
sudo yum install tk sudo yum install tk-devel sudo yum install tc
and it says packages are already installed and nothing to to
I have set up my virtual environment again to see if I missed something but I cannot get anywhere. Please help!
The simplest method to install Tkinter in a Windows environment is to download and install either ActivePython 3.8 or 3.7 from here. Alternatively, you can create and activate a Conda environment with Python 3.7 or greater that is integrated with the latest version of Tkinter.
Import the Tkinter module. Create the GUI application main window. Add one or more of the above-mentioned widgets to the GUI application. Enter the main event loop to take action against each event triggered by the user.
To install tkinter in Pycharm, install the module “future” and restart pycharm. Tkinter will be imported.
Try this
sudo apt-get install python3-tk
this worked for me
Try with apt-get install python-tk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With