How do I link the ActiveState distribution of Tcl/Tk to HomeBrew installed Python How do I link the ActiveState distribution of Tcl/Tk to HomeBrew installed Python python python

How do I link the ActiveState distribution of Tcl/Tk to HomeBrew installed Python


tcl-tk can be installed via Homebrew and one can have the Homebrew installed python linked to that version (Homebrew installed) of tcl-tk.
The only "barrier" to that, is to enable the right homebrew tap, as tcl-tk is not found in the "default" taps in Homebrew.
Indeed tcl-tk is found in the tap called homebrew-dupes which contain (cite the page)

formulae that duplicate software provided by macOS, though may provide more recent or bugfix versions.

Here the link to homebrew-dupes:
https://github.com/Homebrew/homebrew-dupes
and here the formula for tcl-tk
https://github.com/Homebrew/homebrew-dupes/blob/master/tcl-tk.rb

So the complete recipe to solve the problem would be:

  1. Activate/Install the homebrew-dupes tap
  2. Install tcl-tk
  3. Install homebrew python using homebrew tcl-tk

The commands to be executed follow:

  1. brew tap homebrew/dupes
  2. brew install tcl-tk
  3. brew install python --with-tcl-tk


Homebrew is an excellent package manager and while installing any package it is recommended to see the info.

brew info python

shows a lot of options that can be passed; but the most important one is

--with-tcl-tk

Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)


I can think of a couple of messy solutions -

1) Insert the actual location of the installed module at the beginning of the path

import syssys.path.insert(1, 'YourTclLocation')

2) Append the new location and remove the previous location

import syssys.path.append('YourTCLLocation')sys.path.remove('ProblemLocation')import Tcl

3) Set PYTHONPATH environment variable in bash and make sure it doesn't have the broken location