unable to install/import tkinter

I got a pretty confusing Problem:

I build a python program using tkinter. Then I dist-upgraded my ubuntu 13.10 (amd64) to ubuntu 14.04 LTS, now I tried to run my tkinter program. My compiler told me

ImportError: No module named tkinter

(The same with Tkinter or tk/Tk) Then I tried to reinstall tkinter using pip:

$ pip install tkinter


Could not find any downloads that satisfy the requirement tkinter
   Cleaning up...
   No distributions at all found for tkinter

again the same with Tkinter, tkinter, tk and Tk

So what happened? Have I got to run something like

$ pip update

(because tk is not anymore in the pip-repository) But why is it not installed anymore on my pc?

Edit: 1. I do not have no root access 2. in the pip.log is

>

  Downloading/unpacking tk   Getting page
> https://pypi.python.org/simple/tk/   Could not fetch URL
> https://pypi.python.org/simple/tk/: 404 Client Error: Not Found   Will
> skip URL https://pypi.python.org/simple/tk/ when looking for download
> links for tk   Getting page https://pypi.python.org/simple/   URLs to
> search for versions for tk:   * https://pypi.python.org/simple/tk/  
> Getting page https://pypi.python.org/simple/tk/   Could not fetch URL
> https://pypi.python.org/simple/tk/: 404 Client Error: Not Found   Will
> skip URL https://pypi.python.org/simple/tk/ when looking for download
> links for tk   Could not find any downloads that satisfy the
> requirement tk

something pretty close happened when I tried To install something using apt on my RaspberryPi without running

$ apt-get update

for a few months

I'd be glad for some help.


Try this:

sudo apt-get install python-tk

or, since your question is tagged as python3, this:

sudo apt-get install python3-tk

python-tk cannot be installed using pip.

As tk is TkInter (-> Interface to TK, which is written in C(++) ) you need to install the C(++) Library TK.

you cannot install this library using pip, as pip is designed to install (mainly)[1]pure python packages. By the way you would not have the sufficient rights to install the library. So you need to ask your superuser for help.

The only way to install it is using

sudo apt-get install python-tk # python2

or

sudo apt-get install python3-tk #python3

And last but not least you would have to use pip3 to install packages for python3.

It is the same as you cannot install freetype using pip.

Note: it is better to use python3 -m pip instead of pip3, as there might be multiple python3 installations on your machine (e.g. python3.4 and python3.5.1)

[1]: Actually pip is able to compile C/C++ Libraries, but it does not seem like it is able to install System-Libraries. Or one will create this package in future.