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`
Install Tkinter on macOSTo install Python and Tkinter on macOS I recommend you use Homebrew. Homebrew is a package manager for command-line software on macOS. Homebrew has both Python 3 and Tkinter available in their repositories. This is also available to copy and paste from the Homebrew homepage.
To install Tkinter, we need Python pre-installed. Tkinter actually comes along when we install Python. While installing Python, we need to check the td/tk and IDLE checkbox. This will install the tkinter and we need not install it separately.
The simplest method to install Tkinter in a Windows environment is to download and install ActivePython 3.8 from here. Alternatively, you can create and activate a Conda environment with Python 3.7 or greater that is integrated with the latest version of Tkinter.
After trying a bunch of things, this is how it finally worked:
$ brew install python-tk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With