9

Using Python 3.8.0 on Mac OS 10.15.3 (Catalina) with pyenv.

When I try to run a file, it returns:

ModuleNotFoundError: No module named '_tkinter'

I've tried brew install tcl-tk. I'm a little worried that because I'm running python on top of pyenv, any third party tkinter module doesn't get run properly.

Running brew doctor returned:

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  `/Users/jm/.pyenv/shims/python3.7-config
  /Users/jm/.pyenv/shims/python3.7m-config
  /Users/jm/.pyenv/shims/python-config
  /Users/jm/.pyenv/shims/python3-config
  /Users/jm/.pyenv/shims/python3.8-config`
doctopus
  • 5,349
  • 8
  • 53
  • 105
  • What do `brew doctor` and `brew upgrade python3` commands show? – Redowan Delowar Feb 10 '20 at 04:36
  • Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew-provided script of the same name. We found the following "config" scripts: `/Users/jm/.pyenv/shims/python3.7-config /Users/jm/.pyenv/shims/python3.7m-config /Users/jm/.pyenv/shims/python-config /Users/jm/.pyenv/shims/python3-config /Users/jm/.pyenv/shims/python3.8-config` and `brew upgrade python3` returned `Warning: python3 3.7.6_1 already installed` – doctopus Feb 10 '20 at 04:39
  • Try removing the `python3.7` configs. See this [issue](https://discourse.brew.sh/t/python3-installation-with-tkinter/3636). – Redowan Delowar Feb 10 '20 at 04:55
  • will it affect my pyenv setup though? – doctopus Feb 10 '20 at 05:10
  • Related question: https://stackoverflow.com/questions/36760839 – phoenix Jul 20 '21 at 17:55

3 Answers3

9

After trying a bunch of things, this is how it finally worked:

$ brew install python-tk
subtleseeker
  • 4,415
  • 5
  • 29
  • 41
0

try to use pip3 it's working in my pip3 install tk

  • 1
    When using Python there are a number of library management systems such as pip. My advice would be to only use one of them. I would also recommend Anaconda Navigator, which does all this stuff automatically. – nerak99 Apr 28 '21 at 13:05
-1

You should install tkinter. To install tkinter write this on console:

pip install tk
stuckoverflow
  • 625
  • 2
  • 7
  • 23
mmc
  • 1