kakyo
kakyo

Reputation: 11590

Updating tcl/tk version of Homebrew python3 on macOS

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.

Upvotes: 4

Views: 8155

Answers (3)

Amir
Amir

Reputation: 309

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!

Upvotes: 0

OctavianX
OctavianX

Reputation: 1

This post provides a neat way:

https://stackoverflow.com/a/60469203/10606936

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

Keypoint is provide the correct ENV for installtion.

Upvotes: 0

kakyo
kakyo

Reputation: 11590

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.

Upvotes: 8

Related Questions