问题描述
在Macos中,当我编译一个python程序时,它出现: _tkinter TclError: 找不到包 tix
如何重新爱上它?
解决方法
这是我的问题,花了我一整天的时间,我只是想记录下来或帮助别人。
下载软件
-
下载xQuartz: download xQuartz
-
下载 Tcl 8.5 和 Tk 8.5
(1) 网络链接转到:Tcl Tk download link
(2) 在网页底部,选择您想要的版本。
I choose the tcl8519-src.zip and the tk8519-src.zip
(3)记住:需要下载同一个版本。
-
下 Tix 8.4,版本可能与 tcl/tk 不同。
网页链接是: Tix download
准备*
-
你可以得到:XQuartz-2.8.1.dmg,只需打开并使用默认选项安装即可。
-
创建一个名为“src”的目录,建议不要更改“src”目录名。
-
将所有三个 zip 文件移动到 src 目录。
-
双击,解压三个文件即可。
编译
-
编译tcl
[ 提示:不需要 make install ]
cd /Users/lee/tcltktix/src/tcl8.5.19/macosx/ ./configure --enable-threads --enable-symbols --enable-shared --enable-framework --enable-64bit make
-
编译tx,并安装
[重要] --with-tcl=**** 替换你的真实目录。
“dir--with-tcl”的最后一个字符,必须是“/”
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
- 编译并安装Tix
[重要] --with-tcl=**** --with-tk=**** 替换你的真实目录。
“dir--with-**”的最后一个字符,必须是“/”
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
现在已经安装了 Tix。
问题
-
如果接收找不到 tclConfig.h:
检查编译配置命令集中的目录,是否有“/”是最后一个字符?
2.如果你mac反馈一个致命错误:'X11/Xlib.h' file not found during compile,you should link the file:
ln -s /opt/X11/include/X11 /usr/local/include/X11
检查
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()
>>>
现在,出现了一个标题为“tix”的窗口。
恭喜!!!