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 命令也不能使用了

找到說明:https://stackoverflow.com/questions/6619307/virtualenv-command-not-found-after-installed-with-macports


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM