AnkP
AnkP

Reputation: 651

No matching distribution found for tkinter

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!

Upvotes: 30

Views: 62129

Answers (7)

mellifluous
mellifluous

Reputation: 2975

sudo yum install python-tools -y

This worked for me on Amazon Linux 2.

Upvotes: 0

Calvin Drawbridge
Calvin Drawbridge

Reputation: 74

For people still experiencing this issue, try to change your Python project interpreter. Tkinter should be included by default, but it is possible that your distribution does not have it included. Always download the latest base interpreter from the official site.

Upvotes: 1

Harsh Mathur
Harsh Mathur

Reputation: 558

Try this

sudo apt-get install python3-tk

this worked for me

Upvotes: 44

jacker_wei
jacker_wei

Reputation: 51

I had the same error as you, I try installing dependencies, tk/tcl, but it didn't work. Finally I solved it using:

sudo apt-get update
sudo apt-get install python-tk

on ubuntu16.04

Upvotes: 1

Roy Holzem
Roy Holzem

Reputation: 870

had same issue: yum install tkinter for CentOS and RedHat for python 2.x!

Upvotes: 1

Try with apt-get install python-tk

Upvotes: 1

Edward Park
Edward Park

Reputation: 57

Since you are using python 2.7 tkinter is Tkinter. Try importing Tkinter.

https://docs.python.org/2/library/tkinter.html

Upvotes: -2

Related Questions