Updating tcl/tk version of Homebrew python3 on macOS
Asked Answered
C

3

4

My environment:

macOS 10.13 python 3.7.1 from Homebrew

I'm having lots of Tcl/TK quirks on the stock Tcl/TK 8.5 under /System/Library/Frameworks/Tcl.framework/Versions/8.5/, and would like to upgrade my Tcl/TK.

But with this question I couldn't find any working tips for upgrading, including:

My test results

  1. --with-tcl-tk no longer works with the latest Homebrew. Running brew install python --with-tcl-tk still points to system Tcl/TK 8.5.9.
  2. The above is also tested with an uninstall/install cycle.
  3. Python keeps using system Tcl/TK after installing latest ActiveTcl.
Caprification answered 26/12, 2018 at 10:15 Comment(0)
C
8

After many more failures, I concluded that the easiest way to make this work is to completely forget about Homebrew, uninstall its python packages.

Then install the latest ActiveTcl and then the python.org version instead. The python.org version will work on top of the latest "System" Tcl/TK, which will be refreshed after installing the ActiveTcl. Unfortunately, Homebrew ignores it.

The current 3.7.2 from python.org is compiled with Tcl/TK 8.6.8:

$ python3
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
>>> print(tk.Tcl().eval('info patchlevel'))
8.6.8

After updating it, several bugs like checkbuttons showing wrong checkmarks on a menu disappeared.

Caprification answered 26/12, 2018 at 10:45 Comment(2)
Such a shame for homebrew to just decide to remove options when installing packages. Guess it's either this, to forego homebrew's python and install without a manager, or to wait until a new package is published with python and tcl/TK combined. Thanks for sharing.Khamsin
It's also worth noting that the latest version of tcl/TK is 8.6.9, which is installable through homebrew. ActiveSlate has not yet published the latest binaries. So another thing to think about when not using homebrew.Khamsin
C
0

This post provides a neat way:

https://mcmap.net/q/146053/-unable-to-install-tkinter-with-pyenv-pythons-on-macos

NOT NEEDED to use actviveTk or python.org python installation.

Keypoint is provide the correct ENV for installtion.

Curch answered 24/2, 2021 at 16:24 Comment(0)
P
0
export PATH="$(brew --prefix tcl-tk)/bin:$PATH"
export LDFLAGS="-L$(brew --prefix tcl-tk)/lib"
export CPPFLAGS="-I$(brew --prefix tcl-tk)/include"
export PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig"
export CFLAGS="-I$(brew --prefix tcl-tk)/include"

Then reinstall your python using pyenv. All would work!

Potency answered 2/7, 2023 at 16:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.