python - 如何在centos中安装python3-tk?

标签 python matplotlib tkinter centos

我需要安装 python3-tk 才能使用 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 ~]$ 

但它不起作用。

我该如何解决?

编辑: 从 pip 安装不起作用:

(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 ~]$ 

最佳答案

tkinter 在 coreos 中作为 tkinter 包可用。您可以使用

安装它
sudo yum install tkinter

完成后,您可以像往常一样导入和使用它。

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

对于 Python 3,你可以安装它

sudo yum install python3-tkinter

正如一些用户提到的,它可以作为 python36u-tkinterpython34-tkinter 来使用,具体取决于操作系统。

sudo yum install python34-tkinter
sudo yum install python36u-tkinter

关于python - 如何在centos中安装python3-tk?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40588444/

相关文章:

python - 在 Emacs 中更改 Python 缩进量

python - 如何在 gensim 中加载预训练模型并用它训练 doc2vec?

python - Conda 仅为 env 设置 LD_LIBRARY_PATH

python - 从命令行在 julia 中打印绘图

python - Mac 上的 Tkinter 显示为黑屏

python - 如何在交互模式下跳过 `if __name__ == "__main_ _"`?

python - 在统计注释中自定义 "star"文本格式的 p 值阈值

python - 箱线图不同边的 Matplotlib 刻度方向

python - 锯齿 tkinter 主循环帧持续时间?

python tkinter treeview 右键单击​​(Button-3)事件以选择 TreeView 中的项目