zoukankan      html  css  js  c++  java
  • python INFO: Can't locate Tcl/Tk libs and/or headers

    今天在学python的时候使用Tkinter包的时候出现以下问题:

     File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    
        import _tkinter # If this fails your Python may not be configured for Tk
    
    ImportError: No module named _tkinter

    然后就给python重新安装了一遍 结果发现:

    running install
    running build
    running build_ext
    INFO: Can't locate Tcl/Tk libs and/or headers
    
    Python build finished, but the necessary bits to build these modules were not found:
    _bsddb             _curses            _curses_panel   
    _sqlite3           _tkinter           bsddb185        
    dbm                dl                 gdbm            
    imageop            sunaudiodev                        
    To find the necessary bits, look in setup.py in detect_modules() for the module's name.

    是少了Tcl/Tk,于是就直接 apt-get install tcl     apt-get install tk 安装了tcl和tk库 ,然后又执行  python setup.py install  安装  python:

    结果还是不行,还是提示Can't locate Tcl/Tk libs and/or headers 郁闷呀;

    然后就又百度了下 找到一篇博客:http://www.linuxdiyf.com/viewarticle.php?id=55587 讲的比较详细:

    原来setup.py 安装的时候要寻找tcl.h和tk.h两个头文件,但是我用find / -name tcl.h在整个linux范围内都没有找到这个头文件。

    再仔细看python.org/topics/tkinter/给出的指导:

    You may have to install Tcl and Tk(when using RPM, install the –devel RPM as well) and /or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning “make” should build the _tkinter extension.

    所以我要安装tcl-devel(我的系统是debian安装的是tcl-dev)和tk-devel(我的系统是debian安装的是tk-dev)才能有头文件,安装tcl/tk,只是把静态或者动态库考到lib目录下,只有tcl-devel(tc-dev),tk-devel(tk-dev)才会把头文件放到/usr/include里边,而_tkinter要编译必须找到这些头文件。

    然后我就执行了 

    apt-get install tcl-dev    

    apt-get install tk-dev 

    安装完这两个包后问题就解决了。。。

  • 相关阅读:
    码农雷林鹏:php环境搭建
    HashMap底层实现原理
    Java基础面试题
    ==和equals的区别,为什么重写equals要重写hashCode
    Java8 函数式接口,方法引用,stream
    ArrayList、Vector、LinkedList的区别
    第二章——信息的表示和处理
    第一章——计算机系统漫游
    通过zuul修改请求参数——对请求参数进行解密
    Java 扫描实现 Ioc 动态注入,过滤器根据访问url调用自定义注解标记的类及其方法
  • 原文地址:https://www.cnblogs.com/phpfarmer/p/4371812.html
Copyright © 2011-2022 走看看