如何在centos中安装python3-tk?
我需要安装python3-tk才能使用matplotlib。如何在centos中安装python3-tk?
I have tried:
(python_3.4_numerical) [[email protected] ~]$ 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) [[email protected] ~]$
但它不工作。
我该如何解决?
编辑: 从PIP安装不起作用:
(python_3.4_numerical) [[email protected] ~]$ 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) [[email protected] ~]$
Tkinter的是coreos为tkinter
封装。您可以安装它
sudo yum install tkinter
一旦完成,您可以像往常一样导入和使用它。
对于Python 3,你可以使用
sudo yum install python3-tkinter
安装它。
当我尝试Python脚本时,它会抛出一个错误?没有可用的包python3-tkinter。 错误:无事可做 –
您正在使用哪个版本的操作系统? – ChillarAnand
请尝试以下命令。
sudo yum install python3-tkinter
现在测试你的终端:
>>> import tkinter
>>> tkinter._test()
我花了很多时间在这个问题上,这里是我的解决方案有效:
yum -y install tkinter tcl-devel tk-devel
到你的Python目录:
vim ......./Python3.5.1/Modules/Setup.dist
删除这些评论行:
_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
结果:
[[email protected] 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
>>>
我使用这两个指令100%
sudo yum -y update
sudo yum -y install python36u-tkinter
这取决于你的Python版本解决了同样的问题。对于Python 3.4它是sudo yum install python34-tkinter
安装python-pip为您的python 3.4安装并使用它。 –
我已经尝试从点子isntall,但它不起作用。什么是正确的命令? – Donbeo
大多数Linux已经安装了Python,所以你不必安装。你有没有在Python中检查'import tkinter'? – furas