mac pyenv installation tkinter, problem-solving environment tkinter

These days written a reptile, because to get the size of the browser, so called tkinter, found that the test actually had an error, this error:
ModuleNotFoundError: No Module named '_tkinter'
impression that this is a mistake in the windows inside encountered before window10 forget that there is a tcl option is selected during installation. Search the next, most occur in the following scenarios:
1.MacOS Mojave
2.pyenv
my system is just now is: MacOS Mojave, and uses pyenv, in both cases I just met.
Since the encounter will want a way to solve it.
Internet gives: brew install tcl-tk to solve this problem, it is regrettable that this method has no effect on me.
To the official website of python found under: https://www.python.org/download/mac/tcltk/
I found a description of it:
mac pyenv installation tkinter, problem-solving environment tkinter

It seems to be the top website to download a tcl-tk package: https://www.activestate.com/products/tcl/downloads/
want to download this package, it must first sign up for an account, but also to create a new project.

mac pyenv installation tkinter, problem-solving environment tkinter
Said here: It is best not to download the latest version, python support for the latest version is not very friendly, recommended download 8.5.
After installation, there will be ModuleNotFoundError: No module named '_tkinter' this error, reason is simple, when pyenv installation of python, tcl-tk is not installed. A very short answer to solve this problem, reinstall under python like,
I was python3.7.3, so execution pyenv install 3.7.3.
Before installing the virtual environment after reloading and dependencies will exist, if there is a problem of dependence worry, you can rely on at the library to export a backup first.
Now the test: python -m tkinter -c 'tkinter._test ( )'
mac pyenv installation tkinter, problem-solving environment tkinter
appear on the map, then it would prove that the installation was successful, tkinter be happy to use the.

Guess you like

Origin blog.51cto.com/14730644/2477659