我在MacOS10.15.7 (Catalina)上使用python 3.9.1。Python是用自制软件安装的。当我导入tkinter时,我得到了8.5.9版本,而我想要的是8.6版本。
brew info tcl-tk
给出
tcl-tk: stable 8.6.10 (bottled) [keg-only]
Tool Command Language
https://www.tcl-lang.org
/usr/local/Cellar/tcl-tk/8.6.10 (3,022 files, 50.9MB)
Poured from bottle on 2020-03-10 at 17:57:25
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/tcl-tk.rb
License: TCL
==> Dependencies
Required: openssl@1.1 ✔
==> Caveats
tcl-tk is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have tcl-tk first in your PATH run:
echo 'export PATH="/usr/local/opt/tcl-tk/bin:$PATH"' >> /Users/saul/.bash_profile
For compilers to find tcl-tk you may need to set:
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
For pkg-config to find tcl-tk you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"
==> Analytics
install: 362,394 (30 days), 390,184 (90 days), 474,512 (365 days)
install-on-request: 9,609 (30 days), 17,845 (90 days), 60,715 (365 days)
build-error: 0 (30 days)
我将建议的行放在我的bash_profile
中,但它们似乎没有任何效果。
>>> import tkinter
>>> tcl = tkinter.Tcl()
>>> print(tcl.call("info", "patchlevel"))
8.5.9
我在网上发现了很多关于这个问题的东西,但似乎都和pyenv有关,我不使用它,除了上面描述的那些似乎与我的情况有关的东西之外,我找不出其他的东西。
我该怎么办?
编辑
我也尝试将这些行添加到我的.bashrc文件中,但这没有任何效果。
发布于 2021-01-30 00:03:41
显然我的蟒蛇已经过时了。(我从来没有想到过,因为这是上个月的事。)不管怎样,
brew update && brew upgrade python@3.9
固定的东西。
发布于 2021-04-19 22:28:57
Brew本身提供了python3.9的解决方案。您只需安装单独的软件包:
brew install python-tk@3.9
https://stackoverflow.com/questions/65910347
复制相似问题