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中。

相关推荐
luojiaao4 分钟前
【Python工具开发】k3q_arxml 简单但是非常好用的arxml编辑器,可以称为arxml杀手包
开发语言·python·编辑器
英英_14 分钟前
视频爬虫的Python库
开发语言·python·音视频
猛犸MAMMOTH19 分钟前
Python打卡第46天
开发语言·python·机器学习
SY.ZHOU40 分钟前
Significant Location Change
macos·ios·cocoa
多多*1 小时前
微服务网关SpringCloudGateway+SaToken鉴权
linux·开发语言·redis·python·sql·log4j·bootstrap
梓仁沐白1 小时前
【Kotlin】协程
开发语言·python·kotlin
Java Fans1 小时前
在WPF项目中集成Python:Python.NET深度实战指南
python·.net·wpf
豌豆花下猫1 小时前
Python 潮流周刊#105:Dify突破10万星、2025全栈开发的最佳实践
后端·python·ai
嘻嘻哈哈OK啦2 小时前
day46打卡
python
木头左2 小时前
Docker容器化技术概述与实践
python