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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 转载自:https://districtdatalabs.silvrback.com/modern-methods...
    Traeyee阅读 1,414评论 0 0
  • Python画图之总结待整理 https://morvanzhou.github.io/tutorials/dat...
    jiandanjinxin阅读 17,694评论 1 14
  • 按:plot,figure,Axes这些名词很烦,不尝试翻译了。 Ipython Notebook比较适合演示ma...
    mhye阅读 7,185评论 1 8
  • 对以往的dns知识进行补充 域名系统(服务层) 是由众多层次名字服务器实现的分布式数据客户端如果想得到www.am...
    lqsss阅读 310评论 0 0
  • 时钟滴答滴答响个不停 该来的人还是没来 该走的人也还没走 而我还在原地等你
    木头人不爱木头人阅读 150评论 0 0

友情链接更多精彩内容