Python tcl没有正确安装 [英] Python tcl is not installed properly

查看:2158
本文介绍了Python tcl没有正确安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚为python安装了graphics.py。然后,当我尝试运行以下代码时:

  from graphics import * 

def main( ):
win = GraphWin(My Circle,100,100)
c = Circle(点(50,50),10)
c.draw(win)
win .getMouse()#暂停查看结果
win.close()#完成后关闭窗口

main()

我的解释器给了我这个奇怪的信息:

  Traceback(最近的调用最后):
在< module>文件中,第8行的文件F:\CS 101 \Python\projects\packer.py
从图形导入*
文件F:\CS 101 \Python\lib\site-packages\graphics.py,第168行,位于< module>
_root = tk.Tk()
在__init__
self中的文件F:\CS 101\Python\lib\tkinter\__init __。py,行1674。 tk = _tkinter.create(screenName,baseName,className,interactive,wantobjects,useTk,sync,use)
_tkinter.TclError:在以下目录中找不到可用的init.tcl:
{F :\ CS 101 \Python\tcl\tcl8.5.9} {F:/ CS 101 / Python / tcl / tcl8.5} {F:/ CS 101 / Python / lib / tcl8.5} {F: / CS 101 / lib / tcl8.5} F:/lib/tcl8.5 {F:/ CS 101 / library} F:/ library F:/tcl8.5.2/library F:/tcl8.5.2/library

F:/ CS 101 / Python / tcl / tcl8.5 / init.tcl:软件包Tcl的版本冲突:有8.5.2,完全需要8.5.9
版本的软件包 Tcl:有8.5.2,在执行
时需要8.5.9
package require -exact Tcl 8.5.9
(文件F:/ CS 101 / Python / tcl / tcl8.5 / init.tcl第20行)

中调用$ {$ {$ f $ / $ $ $ / Python / tcl / tcl8.5 / init.tcl}
(高级身体里ne 1)从
uplevel#0 [列表源$ tclfile]中调用



这可能意味着Tcl没有正确安装。

这是什么意思?我可以做什么?



PS:我使用Eclipse(PyDev)进行编码。

解决方案关于你可以做什么,你可以尝试编辑你的init.tcl文件来读取类似 package require Tcl 8.5.0-8.6 ,或者如果这不起作用,你可以试试 package require -exact Tcl 8.5.2 。我也必须以相同的方式编辑我的tcl \ tk8.5 \ tk.tcl文件,对于Tk而不是Tcl。



如果编辑文件不适用于您,您可以从以下位置下载并安装最新版本的Tcl:




  • 一个href =http://sourceforge.net/projects/tcl/files/Tcl/> sourceforge 。这将需要有一个可接受的编译器。例如,请参阅 blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express / stackoverflow.com/questions/4218613/building-a-python-module-on-windows-using-ms-compiler

  • 最新的 ActiveState社区版本。如果您有权限安装,这可能是最简单的选择。鉴于这是针对CS 101的,您的实验室管理员可能不会允许您获得该权限(无论是通过策略还是技术)。当然,这也可能意味着这个答案来得太迟,无法帮助您的直接需求。
  • 没有更多的信息,我现在只能做出猜测。我有相反的问题;我会告诉你,希望它能让你了解它的含义。

    我已经安装了8.5.9,但是init.tcl需要8.5。 2。我猜我的问题是由于安装了ActiveState python,然后是官方的python(2.7,64位)和/或我以后安装的其他软件包造成的。在此下载页面的底部有一个关于MacOS上Tcl / Tk的说明,可以解释意味着PC上也有麻烦的空间。 ActiveState Python 2.7包含Tcl / Tk 8.5.9,如此处所述。使用 7-zip 打开ActiveState和Python.org中的msi文件,并查找tcl,然后require ,我可以看到ActiveState msi中的init.tcl指定了 package require -exact Tcl 8.5.9



    我的猜测是8.5.2的要求来自于常规的python安装(显然不太可能)或者稍后安装的一些软件包。在修复模式下运行ActiveState msi不能解决问题,也不能在修复模式下运行Python msi。



    PS如果这不是及时的,为什么我仍然回答?为你制定一个体面的答案帮助我更好地理解我的问题。


    I just installed graphics.py for python. Then, when I tried to run the following code:

        from graphics import *
    
        def main():
            win = GraphWin("My Circle", 100, 100)
            c = Circle(Point(50,50), 10)
            c.draw(win)
            win.getMouse() # Pause to view result
            win.close()    # Close window when done
    
        main()
    

    My interpreter gave me this strange information:

    Traceback (most recent call last):
    File "F:\CS 101\Python\projects\packer.py", line 8, in <module>
    from graphics import *
    File "F:\CS 101\Python\lib\site-packages\graphics.py", line 168, in <module>
    _root = tk.Tk()
    File "F:\CS 101\Python\lib\tkinter\__init__.py", line 1674, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects,                            useTk, sync, use)
    _tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    {F:\CS 101\Python\tcl\tcl8.5.9} {F:/CS 101/Python/tcl/tcl8.5} {F:/CS        101/Python/lib/tcl8.5} {F:/CS 101/lib/tcl8.5} F:/lib/tcl8.5 {F:/CS 101/library} F:/library     F:/tcl8.5.2/library F:/tcl8.5.2/library
    
    F:/CS 101/Python/tcl/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.2,            need exactly 8.5.9
    version conflict for package "Tcl": have 8.5.2, need exactly 8.5.9
    while executing
    "package require -exact Tcl 8.5.9"
    (file "F:/CS 101/Python/tcl/tcl8.5/init.tcl" line 20)
    invoked from within
    "source {F:/CS 101/Python/tcl/tcl8.5/init.tcl}"
    ("uplevel" body line 1)
    invoked from within
    "uplevel #0 [list source $tclfile]"
    
    
    This probably means that Tcl wasn't installed properly.
    

    What does it mean? What can I do?

    PS: I am using Eclipse (PyDev) for coding.

    解决方案

    Regarding what you can do, you can try editing your init.tcl file to read something like package require Tcl 8.5.0-8.6, or if that doesn't work you can try package require -exact Tcl 8.5.2. I also had to edit my tcl\tk8.5\tk.tcl file in the same way, for Tk instead of Tcl.

    If editing the file does not work for you, you can download and install the latest Tcl from:

    • source using the latest version from sourceforge. This will require having an acceptable compiler. For example, see blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/ or stackoverflow.com/questions/4218613/building-a-python-module-on-windows-using-ms-compiler.
    • the latest ActiveState community version. This may be the easiest option if you have permission to install. Seeing that this is for CS 101, your lab administrators might not allow you that permission (whether by policy or technology). Of course, that also probably means this answer comes too late to help with your immediate need.

    Regarding what it means, without more information, I can only make conjectures right now. I had the reverse problem; I will tell you about it in hopes that it gives you some insight into what it might mean.

    I have 8.5.9 installed, but init.tcl was requiring 8.5.2. I'm guessing my problem was caused by installing ActiveState python, then official python (both 2.7, 64-bit), and/or additional packages I installed later. There is a note at the bottom of this download page regarding Tcl/Tk on MacOS that one could interpret to mean there is room for trouble on the PC as well. ActiveState Python 2.7 includes Tcl/Tk 8.5.9, as documented here. Using 7-zip to open the msi files from ActiveState and Python.org, and grepping for "tcl" and then "require", I can see that the init.tcl in the ActiveState msi specifies package require -exact Tcl 8.5.9.

    My guess is that the 8.5.2 requirement came from the regular python install (which is apparently less grepable), or some package I installed later. Running the ActiveState msi in repair mode does not fix the issue, nor does running the Python msi in repair mode.

    P.S If this isn't timely, why did I still answer? Crafting a decent answer for you helped me understand my issue better.

    这篇关于Python tcl没有正确安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆