version conflict for package "Tk": have 8.5.2, need exactly 8.5.15
Asked Answered
H

2

8

I am trying to compile a program (python2.7) but no matter what I do I keep getting this error:

C:/Python27/tcl/tk8.5/tk.tcl: version conflict for package "Tk": have 8.5.2, need exactly 8.5.15
version conflict for package "Tk": have 8.5.2, need exactly 8.5.15
while executing
"package require -exact Tk  8.5.15"
    (file "C:/Python27/tcl/tk8.5/tk.tcl" line 18)
    invoked from within
"source C:/Python27/tcl/tk8.5/tk.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $file]"

This probably means that tk wasn't installed properly.

Can someone please explain to me what's the problem here?

Hundred answered 3/11, 2014 at 0:10 Comment(5)
Sounds like you need a different version of Tk. Have you tried uninstalling the current version and running pip install Tk==8.5.15?Individual
I'm sorry for my ignorance, but how do I do that? I have never used Tcl before (not really sure what it is). Even inside my code I never "use Tcl" explicitly, probably one of my imported libraries does.Hundred
pip uninstall tk and then run the line from my previous commentIndividual
I should probably mention I'm running Windows 7. Not sure if relevant, but I think that's a terminal command.Hundred
pip works in windows. It takes some more setup but it's possible to get it working. I don't use Windows personally so I wouldn't know how to set it up.Individual
S
18

step 1: open C:\Python27\tcl\tcl8.5\init.tcl

if {[info commands package] == ""} {
    error "version mismatch: library\nscripts expect Tcl version 7.5b1 or later but the loaded version is\nonly [info patchlevel]"
}
package require -exact Tcl 8.5.15 

8.5.15 changed to 8.5.2

step 2: open C:\Python27\tcl\tk8.5\tk.tcl

package require Tcl 8.5 ;# Guard against [source] in an 8.4- interp before
            ;# using 8.5 [package] features.
# Insist on running with compatible version of Tcl
package require Tcl 8.5.0
# Verify that we have Tk binary and script components from the same release
package require -exact Tk  8.5.15

8.5.15 changed to 8.5.2

Swill answered 14/3, 2016 at 11:52 Comment(2)
In case anyone else runs into this problem: I was creating a distribution package using py2exe. I got a similar error to the one in the original post. The tcl in my Python27 directory was fine, but I had to change the tk.tcl in the dist directory that got created by py2exe in my project folder. Just make sure you look at the path of the error message so you know which one to change.Rhythmics
Why is this upvoted? This is basically gaming the system. Who knows what kind of errors this will lead to down the road?Idolize
A
0

Tk comes in (conceptually) two pieces:

  1. the dynamic library file that implements the views
  2. the script library file(s) that implements the default controllers.

These must be exactly matched to each other (it's the only way in which they are warranted to work correctly). By default, the Tk DLL includes the path where it can find its scripts, but it can be overridden by environment variables; that mechanism is mainly intended to support pre-installation testing, though sometimes it gets used rather more than it really ought.

You appear to have configured things so that you have one version of the DLL (8.5.2) whereas a different version of the scripts (8.5.15). This could be because you've linked against the wrong version of the DLL, or because you have an environment variable (TK_LIBRARY) set to point to the wrong installation. Which it is is a little hard to tell from the error message: all it really says is that there is a version mismatch.

Aardvark answered 4/11, 2014 at 9:15 Comment(1)
I've seen this problem a few times with Python installations: I suspect they're doing something wrong which they usually get away with…Aardvark

© 2022 - 2024 — McMap. All rights reserved.