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
You just need to copy two folders from tcl folder to the Lib folder
tcl8.5 and tk8.5
If you are hitting this kind of error in a python -m venv NAME
kind of virtual environment (and you actually have tcl installed in your system), then you need to export the paths similarly as suggested by Kamil Czerski in a previous post for virtualenv.
import tkinter root = tkinter.Tk() print(root.tk.exprstring('$tcl_library')) print(root.tk.exprstring('$tk_library'))
bin/activate
and find the place where they export PATH
and insert after this (insert correct paths from step 1):TCL_LIBRARY="/tcl/path/from/step/1" TK_LIBRARY="/tk/path/from/step/1" TKPATH="/tk/path/from/step/1" export TCL_LIBRARY TK_LIBRARY TKPATH
deactivate source bin/activate
The "Tcl missing"-error should be gone.
Hit a similar problem after installing Activestate Python and TCL. I found the following page solved the problem for me: ActiveState Python install problem. The fix was to copy the contents of C:\Python27\tcl
into C:\Python27\Lib
.
Another potential solution (given by user i-shenl in a different ActiveState thread on the same issue) is to set the environment variable $TCL_LIBRARY to point to the tcl library folder ("C:/Python27/tcl", in the question). If you set this system-wide or account-wide (via System Properties), it will affect other programs that use a TCL Library (if any are installed). If you're using Powershell, you can set this variable in your profile to limit its affects to programs run from the shell.
All you need to do is copy tcl 8.6
and tcl 8.5
from tcl
file to Lib
file on in python
.
Python-tcl-tcl8.5
to Python-Lib
Go to directory in which all of your python dependencies are stored
Example:
Python37
-DLLs
-Doc
-etc
-include
-Lib
-libs
-Scripts
-tcl
-python.exe
Go to tcl folder, copy the tcl8.5 and tk8.5 folder Paste these folders in the Lib folder
This solution works for Windows 10 users
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
workon your-env-name
gedit $VIRTUAL_ENV/bin/postactivate
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
deactivate
and workon your-env-name
again.