14

I need to install python3-tk in order to use matplotlib.

I have tried: 

(python_3.4_numerical) [lpuggini@machinelearn-1 ~]$ sudo yum install python3-tk
[sudo] password for lpuggini: 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.clouvider.net
 * epel: epel.check-update.co.uk
 * extras: mirror.sov.uk.goscomb.net
 * updates: mirrors.clouvider.net
No package python3-tk available.
Error: Nothing to do
(python_3.4_numerical) [lpuggini@machinelearn-1 ~]$ 

but it is not working.

How can I fix it?

EDIT: Installing from pip does not work:

(python_3.4_numerical) [lpuggini@machinelearn-1 ~]$ pip install pygtk
Collecting pygtk
  Using cached pygtk-2.24.0.tar.bz2
    Complete output from command python setup.py egg_info:
    ********************************************************************
    * Building PyGTK using distutils is only supported on windows. *
    * To build PyGTK in a supported way, read the INSTALL file.    *
    ********************************************************************

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-nzjsuhx3/pygtk/
(python_3.4_numerical) [lpuggini@machinelearn-1 ~]$ 
Donbeo
  • 17,067
  • 37
  • 114
  • 188

10 Answers10

22

tkinter is available in coreos as tkinter package. You can install it with

sudo yum install tkinter

Once it is done, you can import and use it as usual.

>>> import tkinter
>>> tkinter._test()

For Python 3, you can install it with

sudo yum install python3-tkinter

As some users mentioned, it is available as python36u-tkinter or python34-tkinter depending on OS.

sudo yum install python34-tkinter
sudo yum install python36u-tkinter
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
6

In Centos 7 you can use:

yum install python36-tkinter
Rajiv Sharma
  • 6,746
  • 1
  • 52
  • 54
3

I solved the same problem using these two commands 100%

sudo yum -y update
sudo yum -y install python36u-tkinter
javac
  • 2,819
  • 1
  • 20
  • 22
3

Or, maybe you are using software collections (SCL), then install the proper tkinter.

search tkinter: yum search tkinter
install proper tkinter such as yum install rh-python36-python-tkinter

Depending on which repository you are using for python, you have different "default" tkinter.

MasaYan
  • 31
  • 2
2

Try the following command.

sudo yum install python3-tkinter

Now Test in your terminal:

>>> import tkinter
>>> tkinter._test()
orvi
  • 3,142
  • 1
  • 23
  • 36
2

I believe tk come with python by default. If so, have you look to reinstall your python 3.4. (I prefer ver3.5). Procedures are mentioned in this website.

Steps:

  1. Download python version

    wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz

  2. Install decoding tool if you don't have: sudo yum install xz-libs

  3. Decode the xz encodeing xz -d Python-3.5.3.tar.xz
  4. Uncompress the decoded file tar -xvf Python-3.5.3.tar
  5. Move the desired directory to install python cd Python-3.5.3
  6. Configure python file ./configure
  7. Build using make
  8. Install using make altinstall
  9. Check if tkinter works. A tk window should pop out. Open a terminal and type the following:

python3.5 import tkinter as tk root = tk.Tk()

The website also has other instructions for installing setuptools and pip which are very useful.

Sun Bear
  • 7,594
  • 11
  • 56
  • 102
2

I spent lots of time on this problem, here is my solution effectively:

  1. yum -y install tkinter tcl-devel tk-devel

  2. to your python directory: vim ......./Python3.5.1/Modules/Setup.dist

Remove comments from these lines:

_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \

-L/usr/local/lib \

-I/usr/local/include \

-ltk8.5 -ltcl8.5 \ # default is 8.2 and you should change it to the version you installed in step1

-lX11

3.

./configure
make && make install

Result:

[root@localhost Python-3.5.1]# python3
Python 3.5.1 (default, Jun 19 2017, 22:43:42) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> 
2

It depends on your python version. For python 3.4 it's sudo yum install python34-tkinter

Baschdl
  • 375
  • 3
  • 15
0

I tried all the other solutions here and none of them work for me. After a bit of research, I found the right package that worked for me.

sudo yum update
sudo yum install rh-python36-python-tkinter

if you use a different version of python3 try searching for your package as I did with

sudo yum search tkinter

and see what option fits your version

Guy
  • 491
  • 4
  • 13
0

for python 3.9 version and on RHEL:

$ sudo yum install python39-tkinter
LeMarque
  • 733
  • 5
  • 21