Solving problems with Python matplotlib modules in MacOSX

Source: Internet
Author: User
Tags python script

There was a problem using the Python matplotlib library on Mac OS X:

>>> import NumPy as NP >>> import Matplotlib.pyplot as Plt Traceback (most recent call last): File "&L T;stdin> ", line 1, in <module> File"/users/david/anaconda2/envs/tensorflow/lib/python3.6/site-packages/ matplotlib/pyplot.py ", line 113, in <module> _backend_mod, New_figure_manager, draw_if_interactive, _show = Pyla B_setup () File "/users/david/anaconda2/envs/tensorflow/lib/python3.6/site-packages/matplotlib/backends/__init__. Py ", line, in Pylab_setup [Backend_name], 0) File"/users/david/anaconda2/envs/tensorflow/lib/python3.6/site-pack ages/matplotlib/backends/backend_macosx.py ", line, in <module> matplotlib.backends import _macosx Runtim Eerror:python is not installed as a framework. The Mac OS X backend won't be able to function correctly if Python isn't installed as a framework. The information on installing Python as a framework on MAC OS X is the Python documentation for the. Please either reinstall Python as A framework, or try one of the other backends. If you are are using (Ana) Conda Please install Python.app and replace the "Python" with ' pythonw '. The ' Working with matplotlib on OS X ' matplotlib FAQ for more information.

2 methods are introduced on the network, which can be tested.

Method One:

Add the following two lines of code to resolve:

>>> import matplotlib
>>> matplotlib.use (' Tkagg ')

# #在import Matplotlib under the module, such as Pyplot before adding the above 2 sentences

>>> import Matplotlib.pyplot as Plt

Method Two:

It's awkward to write in every Python script file.

Add the Matplotlib configuration:

echo "Backend:tkagg" >> ~/.MATPLOTLIB/MATPLOTLIBRC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.