macos _tkinter TclError: can't find package Tix

523 views Asked by At

In Macos,when I compile a python program, it appears: _tkinter TclError: can't find package Tix

How to reslove it ?

1

There are 1 answers

0
leehistory On

This is my question, It cost my whole days, I just want to record it or help others.

Download software

  1. Download xQuartz: download xQuartz

  2. Download Tcl 8.5 and Tk 8.5

    (1) weblink goto:Tcl Tk download link

    (2) in the bottom of the webpage,choose which version you want.

    I choose the tcl8519-src.zip and the tk8519-src.zip
    

    (3) remember: need download the same verion.

  3. Down Tix 8.4, the version could be different to the tcl/tk.

    The weblink is: Tix download

Prepare*

  1. you could got: XQuartz-2.8.1.dmg, just open and install it with default choice.

  2. create a dir named "src", suggest not change the "src" dir name.

  3. move all three zip file to the src dir.

  4. double click ,just unzip all the three file.

Compile

  1. compile tcl

    [ Tips: not need make install ]

    cd /Users/lee/tcltktix/src/tcl8.5.19/macosx/
    ./configure --enable-threads --enable-symbols --enable-shared --enable-framework --enable-64bit
    make
    
  2. compile tx, and install it

[IMPORTANT] --with-tcl=**** replace your real dir.

the last char of "dir--with-tcl", must be "/"

   cd /Users/lee/tcltktix/src/tk8.5.19/macosx/
   ./configure --enable-threads --enable-symbols --enable-shared --enable-framework --enable-aqua  --with-tcl=/Users/lee/tcltktix/src/tcl8.5.19/macosx/
   make
   sudo make install
  1. compile Tix and install it

[IMPORTANT] --with-tcl=**** --with-tk=**** replace your real dir.

the last char of "dir--with-**", must be "/"

   cd /Users/lee/tcltktix/src/Tix8.4.3
   ./configure --enable-threads --enable-shared --enable-framework LDFLAGS="-L/usr/X11/lib" --with-tcl=/Users/lee/tcltktix/src/tcl8.5.19/macosx/  --with-tk=/Users/lee/tcltktix/src/tk8.5.19/macosx/
   make
   sudo make install

NOW the Tix has been installed.

Question

  1. If receieve could not find the tclConfig.h:

    check the dir in your compile configure order set, whether if have the "/" is the last char?

2.If you mac feedback a fatal error: ‘X11/Xlib.h’ file not found during compile, you should link the file:

ln -s /opt/X11/include/X11 /usr/local/include/X11

Check

   MacBook-Air-1531:~ lee$ python3
   Python 3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 18:49:57)
   [Clang 6.0 (clang-600.0.57)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> from tkinter import tix
   >>> 
   >>> root = tix.Tk()
   >>>

Now, a window with title "tix" appeared.

congratulation!!!