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

相关推荐
请为小H留灯1 小时前
Mac 常用操作与维护技巧
macos·电脑·清理电脑·常用技巧
前端精髓2 小时前
结构化输出with_structured_output(抽卡)
python·langchain
尹人入圣3 小时前
目前热门的IP驱动产业新场景新工具
网络·python·网络协议·tcp/ip
Nuanyt4 小时前
Agent 学习笔记(下篇三):上线工程、进阶选择与操作界面(Stage 7 / 7.5 / 8 + 延伸路线)
笔记·python·学习·memory·aiagent·harness
吴卫斌4 小时前
定投ETF实战指南(四):行业/主题ETF——定投的“进攻端“
开发语言·python·股票·量化
2601_967987374 小时前
Python——入门级(定义功能def函数)
python·函数·可变参数·默认参数·关键字参数
专注仿真7 小时前
梯度提升类(XFBoost)算法详解与代码实例
开发语言·人工智能·python·算法·大模型训练·控制算法
外收内放7 小时前
Python基础语法练习题(75)
开发语言·python·学习
黑十8 小时前
PyTorch 报 “no CUDA GPUs are available“ 怎么办?3 步排查
服务器·网络·人工智能·pytorch·python
threelab8 小时前
开源图片去水印代码
python