【发布时间】:2013-02-10 00:25:54
【问题描述】:
我已经广泛阅读了这个问题,但没有找到可用的解决方案。他们中的许多人建议从头开始重建 python。如果可能的话,这是我想避免的障碍。所以我要给这个问题最后一个,绝望的镜头。它不应该与 stackoverflow 上的许多类似问题重复,因为我相信它特定于我的安装,即使症状与其他症状相似。
这是我安装的当前状态。我已经安装了很多其他软件包,例如 numpy 和 matplotlib 没有问题,但是这个让我很困惑。
MacBookPro:lib-tk rebcabin$ arch -x86_64 /opt/local/bin/python
Python 2.7.3 (default, Nov 17 2012, 19:54:34)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', ...
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
...]
注意路径上的lib-tk。我们去看看lib-tk:
MacBookPro:lib-tk rebcabin$ ls -la
total 3704
...
-rw-r--r-- 1 root wheel 155634 Nov 17 19:55 Tkinter.py
-rw-r--r-- 1 root wheel 224887 Nov 17 19:55 Tkinter.pyc
-rw-r--r-- 1 root wheel 224887 Nov 17 19:55 Tkinter.pyo
...
让我们尝试导入它
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
我对这个主题所做的大部分阅读都来自于将上面的错误粘贴到 Google 中。其中一些建议非常花言巧语且毫无用处:“只需在 setup.py 中重新配置你的 python,输入‘make’,你的问题就解决了。”哪个setup.py?我的 python 目录中有几十个。哪个makefile?同上。也许上下文是从头开始构建 python,我将再次避免,因为我不想冒险破坏所有其他有效的包。
【问题讨论】:
标签: python macos tkinter tcl tk