_tkinter.TclError: can't find package comm
_tkinter.TclError: can't find package comm
运行 在尝试使用 comm 包时遇到这个问题:
>>> interp = tkinter.Tcl()
>>> interp.eval('package require comm')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_tkinter.TclError: can't find package comm
我在 windows 10
上使用 python 3.6.8
如果您知道 comm
包的安装目录(包含 pkgIndex.tcl
的目录或 直接父目录 目录),您应该在尝试 package require
包之前确保它在 Tcl 的 auto_path
上。您需要执行的功能是:
def add_library_directory(tcl_context, directory_name):
tcl_context.eval("lappend auto_path {}".format(
# This does the trick to make the string substitution fully safe
tkinter._stringify(directory_name)))
interp = tkinter.Tcl()
# Up to you to actually find the location...
add_library_directory(interp, "/path/to/dir")
interp.eval('package require comm')
有关 tkinter._stringify
的详细信息,尽管它非常有用,但没有大量记录,请参阅另一个 Stack Overflow 问题:
- Pass Python variables to `Tkinter.Tcl().eval()`
解决方案的总结正如@Donal 所解释的那样 and then possibly followed by this next resolution: Python Tkinter throwing Tcl error 通过将包含通讯库的离线版本的 tcl 库指向 python 环境所期望的位置。
运行 在尝试使用 comm 包时遇到这个问题:
>>> interp = tkinter.Tcl()
>>> interp.eval('package require comm')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_tkinter.TclError: can't find package comm
我在 windows 10
上使用 python 3.6.8如果您知道 comm
包的安装目录(包含 pkgIndex.tcl
的目录或 直接父目录 目录),您应该在尝试 package require
包之前确保它在 Tcl 的 auto_path
上。您需要执行的功能是:
def add_library_directory(tcl_context, directory_name):
tcl_context.eval("lappend auto_path {}".format(
# This does the trick to make the string substitution fully safe
tkinter._stringify(directory_name)))
interp = tkinter.Tcl()
# Up to you to actually find the location...
add_library_directory(interp, "/path/to/dir")
interp.eval('package require comm')
有关 tkinter._stringify
的详细信息,尽管它非常有用,但没有大量记录,请参阅另一个 Stack Overflow 问题:
- Pass Python variables to `Tkinter.Tcl().eval()`
解决方案的总结正如@Donal 所解释的那样