Mac安装Python3,遇到IDLE中无法输入中文的问题,shell中显示如下警告
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
上网百度之,猜测是因为mac预装的tcl-tk8.5.9版本不稳定,于是使用homebrew升级至最新版本的8.6.6版本,发现还是不起作用,观察命令行中发现有如下提示:
This formula is keg-only, which means it was not symlinked into /usr/local,
because tk installs some X11 headers and macOS provides an (older) Tcl/Tk.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/tcl-tk/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/tcl-tk/lib
CPPFLAGS: -I/usr/local/opt/tcl-tk/include
于是按照提示修改配置文件发现还是不行查询当前tcl-tk版本显示如下
~ hetunyu$ tclsh
% info patchlevel
8.6.6
但是IDLE中的Tk version一直显示8.5.9
About IDLE很困惑,上网百度、google,答案是让重新使用homebrew方式安装python3
brew reinstall python3 --with-tcl-tk
但是我想尝试找一下原因,于是浏览python官方网站其中提到:How Python Chooses Which Tk Library To Use
Python Choose TK.png
显示Python并不能自动关联Tcl/Tk的8.6版本,只会关联8.5,所以一直会使用系统自带的8.5.9。
知道原因后在activetcl网站重新下载8.5.18.0版本,点击安装,重新运行IDLE,没有任何警告。希望能给需要的朋友节约点时间~
网友评论