ImportError: No module named _tkinter on macos
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 命令也不能使用了