Python Tkinter throwing Tcl error

前端 未结 8 1717
孤城傲影
孤城傲影 2021-02-20 13:23

I am learning basic GUI in Python, and I came across a sample example to read file name from file explorer on Stack Overflow.

from Tkinter import Tk
from tkFileD         


        
相关标签:
8条回答
  • 2021-02-20 14:15

    In case you are using Virtualenv on Windows I found a solution here: https://github.com/pypa/virtualenv/issues/93

    I copied the "tcl" folder from C:\Python27\ over to the root of the new Virtualenv, Tkinter.Tk() shows a new window without throwing an exception.

    I am running Python 2.7 on Windows 7.

    0 讨论(0)
  • 2021-02-20 14:15

    IDLE is probably setting the path required for TCL. To find out what path is being used by IDLE, compare the output of sys.path from IDLE and without IDLE. Then you can add the location of init.tcl either using an environment variable or programatically. See Xenomorph suggestion.

    0 讨论(0)
提交回复
热议问题