Python Tkinter throwing Tcl error -


i learning basic gui in python, , came across sample example read file name file explorer on stack overflow.

from tkinter import tk tkfiledialog import askopenfilename tk().withdraw() # don't want full gui, keep root window appearing filename = askopenfilename() # show "open" dialog box , return path selected file print(filename) 

this particular script working fine when trying run in idle, same not running if trying command prompt in windows 7.

python version: 2.7. here output error get.

>>> tkinter import tk >>> tkfiledialog import askopenfilename >>> tk().withdraw() traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\python27\lib\lib-tk\tkinter.py", line 1685, in __init__ self.tk = _tkinter.create(screenname, basename, classname, interactive, wantobjects, usetk, sync, use) _tkinter.tclerror: can't find usable init.tcl in following directories: c:/python27/lib/tcl8.5 d:/pyproj/lib/tcl8.5 d:/lib/tcl8.5 d:/pyproj/library d:/library d:/tcl8.5.2/library d:/tcl8.5.2/library  means tcl wasn't installed 

any pointer missing here can of great help.

in case using virtualenv on windows found solution here: https://github.com/pypa/virtualenv/issues/93

i copied "tcl" folder c:\python27\ on root of new virtualenv, tkinter.tk() shows new window without throwing exception.

i running python 2.7 on windows 7.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -