【问题标题】:How to make python3 use my pip dependency of tkinter instead of yum tkinter如何让 python3 使用我的 tkinter 的 pip 依赖项而不是 yum tkinter
【发布时间】:2022-10-22 01:37:44
【问题描述】:

我正在使用 python3 tkinter 在 Linux Centos 上构建一个小型 GUI 我已经设置了我的环境并安装了所有依赖项(cython、numpy、panda 等) 当我去安装 tkinter

pip3 install tk
$ python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
>>> No module found: tkinter

尽管 'pip list' 显示了 'tk' 依赖项,但我得到了上述错误,python 仍然抛出错误。依赖项也正确显示在“站点包”中。

但是当我使用 yum 安装 tkinter

sudo yum install python3-tkinter

做同样的事情

python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
>>> tkinter._test()

它工作得很好。

问题是如果我想将所有依赖打包在一起并共享它,tkinter 的工作版本不会在包中,其他用户在构建项目时会感到困惑

为什么 'pip install tk' 没有被识别为 tkinter 的有效安装,但 'sudo yum install python3-tkinter' 有效?所有其他依赖项都与 pip 一起工作,只是 tkinter 被破坏了。如何让 python 识别 pip 安装?

【问题讨论】:

    标签: pip centos python-3.6 dependency-management yum


    【解决方案1】:

    为什么 'pip install tk' 没有被识别为 tkinter 的有效安装,但 'sudo yum install python3-tkinter' 有效?

    因为pip install tk 安装的是 tensorkit,而不是 tkinter。你不能用 pip 安装 tkinter。

    【讨论】:

      【解决方案2】:

      所以我不知道centOS是否使用apt put你可以尝试先用pip卸载tinkter,然后使用apt安装它

      sudo apt-get install python3-tk
      

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 1970-01-01
      • 2021-10-24
      • 2011-02-21
      • 2020-07-28
      • 1970-01-01
      • 2016-08-21
      • 1970-01-01
      • 2022-01-17
      • 2020-05-25
      相关资源
      最近更新 更多