skip to Main Content

I’m using python3 tkinter to build a small GUI on Linux Centos
I have my environment set up with all the dependencies installed (cython, numpy, panda, etc)
When I go to install 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

I get the above error despite ‘pip list’ displaying the ‘tk’ dependency, python still throws the error. The dependency correctly shows up in "site-packages" as well.

But when I use yum to install tkinter

sudo yum install python3-tkinter

and do the same thing

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()

it works perfectly fine.

The issue is that if I want to package all the dependencies together and share it, the working version of tkinter won’t be in the package and other users will be confused when they build the project

Why is ‘pip install tk’ not being recognized as a valid installation of tkinter but ‘sudo yum install python3-tkinter’ works? All the other dependencies work with pip, it’s just tkinter that is broken. How can I make python recognize the pip installation?

2

Answers


  1. so i don’t know if centOS uses apt put you can try first uninstalling tinkter with pip and then use apt to install it

    sudo apt-get install python3-tk
    
    Login or Signup to reply.
  2. Why is ‘pip install tk’ not being recognized as a valid installation of tkinter but ‘sudo yum install python3-tkinter’ works?

    Because pip install tk installs an old package called tensorkit, not tkinter. You can’t install tkinter with pip.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search