Mac RuntimeError: Unable to “import matplotlib.pyplot as plt” in virtualenv

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ
cd ~/.matplotlib
nano matplotlibrc
# add content
backend: TkAgg

或者
Here is a sample python snippet that you can try and test matplotlib.

import matplotlib

matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [0, 3, 7])
plt.show()

參考:
https://stackoverflow.com/questions/29433824/unable-to-import-matplotlib-pyplot-as-plt-in-virtualenv

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 轉載自:https://districtdatalabs.silvrback.com/modern-methods...
    Traeyee閱讀 1,367評論 0 0
  • Python畫圖之總結待整理 https://morvanzhou.github.io/tutorials/dat...
    jiandanjinxin閱讀 17,399評論 1 14
  • 按:plot,figure,Axes這些名詞很煩,不嘗試翻譯了。 Ipython Notebook比較適合演示ma...
    mhye閱讀 7,048評論 1 8
  • 對以往的dns知識進行補充 域名系統(服務層) 是由眾多層次名字服務器實現的分布式數據客戶端如果想得到www.am...
    lqsss閱讀 287評論 0 0
  • 時鐘滴答滴答響個不停 該來的人還是沒來 該走的人也還沒走 而我還在原地等你
    木頭人不愛木頭人閱讀 144評論 0 0