我安装了python3-tkinter,如下所示:
$ 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'
看起来是因为版本'tkiner-3.3',但是'tkinter-3.5'。我尝试使用/usr/bin/python3.3,然后它可以正确导入tkinter。
如何为Python3.5安装tkinter-3.5?
答案 0 :(得分:3)
您同时启用了IUS和nux-desktop repos。似乎nux-desktop有一个名为python3的软件包3.3.2版,带有相关的python3-tkinter软件包。另一方面,IUS具有python34u(3.4.6),python35u(3.5.3)和python36u(3.6.0)的软件包,所有软件包都具有相应的tkinter软件包。因此,如果您希望能够在python3.5 REPL中import tkinter
,请运行:
yum install python35u-tkinter
答案 1 :(得分:0)
对于Python3.5的tkinter安装:
yum -y install tkinter tcl-devel tk-devel
vim ......./Python3.5.#/Modules/Setup.dist
,删除以下行之前的评论symble:
_tkinter _tkinter.c tkappinit.c -
-L/usr/local/lib \
-I/usr/local/include \
-ltk8.5 -ltcl8.5 \ #defualt as 8.2
-lX11
配置并安装
./configure
make
make install
答案 2 :(得分:0)
对于Python 3.6.x
上的CentOS 7.4
,请安装:
$ sudo yum install python36-tkinter
您需要配置EPEL
存储库。
答案 3 :(得分:0)
对于centos 7.6,python 3.4.9,请通过以下方法解决我的问题:
yum install python34-tkinter.x86_64