user697911
user697911

Reputation: 10561

Why doesn't tkinter import on CentOs 7

I have the python3-tkinter installed, as shown below:

$ sudo yum install python3-tkinter
[sudo] password for abigail: 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.supremebytes.com
 * epel: mirrors.kernel.org
 * extras: mirror.supremebytes.com
 * ius: mirrors.kernel.org
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirror.web-ster.com
 * rpmfusion-nonfree-updates: mirror.web-ster.com
 * updates: mirror.supremebytes.com
Package python3-tkinter-3.3.2-12.el7.nux.x86_64 already installed and latest version
Nothing to do

$ /usr/bin/python3.5
Python 3.5.2 (default, Jun 27 2016, 14:02:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'tkinter'

It looks like it's because it is the version 'tkiner-3.3', but 'tkinter-3.5'. I tried use /usr/bin/python3.3, then it can import tkinter correctly.

How to install tkinter-3.5 for Python3.5?

Upvotes: 1

Views: 10014

Answers (4)

ZhangGa
ZhangGa

Reputation: 36

For tkinter installation for Python3.5:

  1. yum -y install tkinter tcl-devel tk-devel
  2. vim ......./Python3.5.#/Modules/Setup.dist, remove the comment symbol before the following lines:

    _tkinter _tkinter.c tkappinit.c - -L/usr/local/lib \ -I/usr/local/include \ -ltk8.5 -ltcl8.5 \ #defualt as 8.2 -lX11

  3. configure and install

    ./configure make make install

Upvotes: 1

alex peng
alex peng

Reputation: 1

For centos 7.6, python 3.4.9, resolve my issue by:

yum install python34-tkinter.x86_64

Upvotes: 0

Soumya Kanti
Soumya Kanti

Reputation: 1479

For Python 3.6.x on CentOS 7.4, install:

$ sudo yum install python36-tkinter

You need to have EPEL repository configured.

Upvotes: 3

carlwgeorge
carlwgeorge

Reputation: 627

You have both IUS and nux-desktop repos enabled. It appears that nux-desktop has a package named python3 of version 3.3.2, with the related python3-tkinter package. IUS on the other hand has packages for python34u (3.4.6), python35u (3.5.3), and python36u (3.6.0), all with corresponding tkinter packages. So if you want to be able to import tkinter inside a python3.5 REPL, then run:

yum install python35u-tkinter

Upvotes: 3

Related Questions