Can‘t find a usable tk.tcl in the following directories 使用报错python tk/tcl

Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
  File "/opt/pycharm-2018.2.8/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 663, in do_enable_gui
    enable_gui(guiname)
  File "/opt/pycharm-2018.2.8/helpers/pydev/pydev_ipython/inputhook.py", line 536, in enable_gui
    return gui_hook(app)
  File "/opt/pycharm-2018.2.8/helpers/pydev/pydev_ipython/inputhook.py", line 285, in enable_tk
    app = _TK.Tk()
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories: 
    /usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/lib/tk8.6 /home/lidada/.virtualenvs/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/library
/usr/local/lib/tk8.6/tk.tcl: version conflict for package "Tk": have 8.6.8, need exactly 8.6.11
version conflict for package "Tk": have 8.6.8, need exactly 8.6.11
    while executing
"package require -exact Tk  8.6.11"
    (file "/usr/local/lib/tk8.6/tk.tcl" line 14)
    invoked from within
"source /usr/local/lib/tk8.6/tk.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $file]"
This probably means that tk wasn't installed properly.

问题所在
Can’t find a usable tk.tcl in the following directories:
version conflict for package “Tk”: have 8.6.8, need exactly 8.6.11
分析:

/usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/lib/tk8.6 /home/lidada/.virtualenvs/lib/tk8.6 /home/lidada/.virtualenvs/lidada_01/library
这是它查找的目录:
cd /usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6
在这里插入图片描述
进入tk.tcl 发现第14行要求为8.6.11 将此处改为8.6.8

在这里插入图片描述
同时将tcl8.6 中的 init.tcl 中,因为

先有tcl,它是一种语言
然后是tk,它是tcl语言下的针对图形界面编程的一个库/包/框架,随你怎么叫,好理解就行
然后是tkinter,它是Python对tk的一个封装(前端,frontend),可以认为是Python图形界面编程的标准库

在这里插入图片描述
将此改为 8.6.8
在这里插入图片描述
如果linux中没有tck/tk 安装教程如该链接:
https://blog.csdn.net/dujie1219/article/details/110235766
本文参考了 http://www.jyguagua.com/?p=589

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值