macos tcl-tk python图形库软件包安装 port 和brew 包管理工具安装方法和使用总结

macos下安装这个tcl-tk 图形库, 使用port和brew 安装时是不一样的, 软件包名称不一样,安装后的软件文件路径信息也不一样。 在brew 包管理工具中,这个软件包的名称就是tcl-tk, 安装方法为 brew install tcl-tk , 而在 port 包管理工具中, 这个图形库被分割为2个软件包, tcl 和 tk, 安装方法为 sudo port install tcl tk

brew 安装 tcl-tk 方法

brew install tcl-tk 安装后的路径信息如下:

安装后的文件路径/usr/local/Cellar/tcl-tk/8.6.15中的文件信息如下

├── bin

│ ├── critcl

│ ├── dtplite

│ ├── mkdoc

│ ├── nns

│ ├── nnsd

│ ├── nnslog

│ ├── page

│ ├── pt

│ ├── tcldocstrip

│ ├── tclsh -> tclsh8.6

│ ├── tclsh8.6

│ ├── wish -> wish8.6

│ └── wish8.6

├── changes

├── include 这个需要添加到 CPPFLAGS环境配置中

│ ├── itk.h

│ ├── itkInt.h

│ └── tcl-tk

├── lib 这个目录需要添加到 LDFLAGS环境配置中

│ ├── Tk.icns

│ ├── Tk.tiff

│ ├── critcl-app3.2

│ ├── critcl-bitmap1.1

│ ├── critcl-class1.2

│ ├── critcl-cutil0.3

│ ├── critcl-emap1.3

│ ├── critcl-enum1.2

│ ├── critcl-iassoc1.2

│ ├── critcl-literals1.4

│ ├── critcl-platform1.1

│ ├── critcl-util1.2

│ ├── critcl3.2

│ ├── itcl4.3.0

│ ├── itk4.1.0

│ ├── libtcl8.6.dylib

│ ├── libtclstub8.6.a

│ ├── libtk8.6.dylib

│ ├── libtkstub8.6.a

│ ├── pkgconfig 这个是pkgconfig目录,需要添加到PKG_CONFIG_PATH环境配置中

│ │ ├── tcl.pc

│ │ └── tk.pc

│ ├── sqlite3.45.3

│ ├── stubs_container1.1

│ ├── stubs_gen_decl1.1

│ ├── stubs_gen_header1.1

│ ├── stubs_gen_init1.1

│ ├── stubs_gen_lib1.1

│ ├── stubs_gen_macro1.1

│ ├── stubs_gen_slot1.1

│ ├── stubs_genframe1.1

│ ├── stubs_reader1.1

│ ├── stubs_writer1.1

│ ├── tcl8

│ ├── tcl8.6

│ ├── tclConfig.sh

│ ├── tcllib1.21

│ ├── tcllibc

│ ├── tclooConfig.sh

│ ├── tcltls1.7.22

│ ├── tdbc1.1.9

│ ├── tdbcmysql1.1.9

│ ├── tdbcodbc1.1.9

│ ├── tdbcpostgres1.1.9

│ ├── thread2.8.10

│ ├── tk8.6

│ └── tkConfig.sh

├── license.terms

├── sbom.spdx.json

└── share

└── man

系统环境变量LDFLAGS,CPPFLAGS, PKG_CONFIG_PATH配置

将下面的代码添加到 ~/.bash_profile 或则 ~/.zshrc 文件中

bash 复制代码
# 编译python时能找到tcl-tk设置
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"

# pkg-config找到tcl-tk的配置:
export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"

# 这个是tcl-tk的可执行文件添加到系统PATH (可以省略)
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"

# tkinter显示设置
export DISPLAY=":0.0"

macport包管理工具 sudo port install tcl tk安装

tcl-tk图形库在port里面被分为2个软件包, 安装命令 sudo port install tcl tk

tcl路径信息

tk的路径信息

~/.bash_profile环境配置

注意,因为port安装后的路径都是安装到了公共的目录/opt/local/文件夹下的相关公共路径中,所以下面这些配置如果已经配置过就不需要再次配置。

bash 复制代码
# 编译python时能找到tcl-tk设置
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"

# pkg-config找到tcl-tk的配置:
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig"

# 这个是tcl-tk的可执行文件添加到系统PATH (可以省略)
export PATH="/opt/local/bin:$PATH"

# tkinter显示设置
export DISPLAY=":0.0"

总结:macos中安装tk库如果网络畅通的话使用brew安装tcl-tk相对于 port方式安装要简单一些,不过brew安装可能会很慢,因为brew的加速仅部分文件加速, 而port的加速是所有依赖包都会被加速。 python库中使用tk的前提是必须先安装tk库和配置好环境变量,然后在编译安装python, 这样tk库才能被编译到python中。

相关推荐
数据智能老司机36 分钟前
精通 Python 设计模式——分布式系统模式
python·设计模式·架构
数据智能老司机2 小时前
精通 Python 设计模式——并发与异步模式
python·设计模式·编程语言
数据智能老司机2 小时前
精通 Python 设计模式——测试模式
python·设计模式·架构
数据智能老司机2 小时前
精通 Python 设计模式——性能模式
python·设计模式·架构
c8i2 小时前
drf初步梳理
python·django
每日AI新事件2 小时前
python的异步函数
python
这里有鱼汤3 小时前
miniQMT下载历史行情数据太慢怎么办?一招提速10倍!
前端·python
databook12 小时前
Manim实现脉冲闪烁特效
后端·python·动效
程序设计实验室12 小时前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三14 小时前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试