Python Tkinter throwing Tcl error

前端 未结 8 1692
孤城傲影
孤城傲影 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条回答
  •  旧时难觅i
    2021-02-20 14:09

    I hit the same problem on Ubuntu 17.04 with virtualenvwrapper for 64 bit Python 2.7

    I add tk and tcl library paths in local postactivate script

    1. Go to your virtualenv: workon your-env-name
    2. Edit local postactiave script with your favourite editor, for ex: gedit $VIRTUAL_ENV/bin/postactivate
    3. Locate tk and tcl library paths. In postactivate script, export TK_LIBRARY and TCL_LIBRARY with appropriate paths. Add this lines to your script with modified paths:

      TK_LIBRARY=/home/kamil/anaconda2/pkgs/tk-8.5 TKPATH=/home/kamil/anaconda2/pkgs/tk-8.5 TCL_LIBRARY=/home/kamil/anaconda2/lib/tcl8.5 export TCL_LIBRARY TK_LIBRARY TKPATH

    4. Restart your virtualenv: deactivate and workon your-env-name again.

提交回复
热议问题