import matplotlib.pyplot as plt File "/Users/admin/.pyenv/versions/3.6.2/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in ..._pyenv matplotlib">
当前位置:   article > 正文

Python中使用matplotlib的报错问题_pyenv matplotlib

pyenv matplotlib
  1. File "get.py", line 14, in <module>
  2. import matplotlib.pyplot as plt
  3. File "/Users/admin/.pyenv/versions/3.6.2/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
  4. _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  5. File "/Users/admin/.pyenv/versions/3.6.2/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
  6. globals(),locals(),[backend_name],0)
  7. File "/Users/admin/.pyenv/versions/3.6.2/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 19, in <module>
  8. from matplotlib.backends import _macosx
  9. 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 using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

 

解决方法:
import matplotlib.pyplot as plt 改成下面的:

  1. import matplotlib
  2. matplotlib.use('TkAgg')
  3. import matplotlib.pyplot as plt

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/714464
推荐阅读
相关标签