MAC OS 10.11.6
lMacBook-Pro:~ xiaomilbq$ python
Python 2.7.14 (default, Sep 22 2017, 00:05:22)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/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
>>>
理論上Tkinter應該是作為Python的默認設置的啊,網上搜索了各種方法,只有以下的方法管用:
sudo port install py27-tkinter
來自:https://stackoverflow.com/questions/6320954/idle-cant-import-tkinter-your-python-may-not-be-configured-for-tk
里面的一個解答
當然,你需要先安裝macport,如果沒有的話
后來看了下 是因為之前用macport安裝了octave導致python版本配置參數被修改了
因為之前安裝了numpy,今天卻無法倒入
pip install 命令也不能使用了
