当前位置:   article > 正文

python安装后无tkinter_Mac pyenv安装python没有tkinter

python3.8无 tkinter

System info:

macOS 10.14.6 (Mojave), tcl-tk 8.6.9, pyenv 1.2.15, and python 3.8.0.

ModuleNotFoundError: No module named '_tkinter'

Install pyenv via homebrew

brew install pyenv

Install tcl-tk via homebrew

brew install tcl-tk

Add environment variables into ~/.zshrc

python pyenv

export PATH="

PATH"

if which pyenv > /dev/null; then

eval "$(pyenv init -)";

fi

pyenv-virtualenv

if which pyenv-virtualenv-init > /dev/null; then

eval "$(pyenv virtualenv-init -)";

fi

tcl-tk

export PATH="/usr/local/opt/tcl-tk/bin:$PATH"

export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"

export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"

export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"

export PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"

Install pyenv-virtualenv via homebrew

brew install pyenv-virtualenv

Install python by pyenv (3.8.0 for example)

pyenv install 3.8.0

Restart shell

exec $SHELL

Create a local environment of python 3.8.0 by pyenv:

pyenv local 3.8.0

pyenv version

Test tcl-tk installation with:

python -m tkinter -c 'tkinter._test()'

or simply:

idle

Job done.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/213672
推荐阅读
相关标签
  

闽ICP备14008679号