Until you install and run matplotlib

When I installed matplotlib and tried to draw a graph, it got stuck more than I expected, so make a note.

environment

Own machine: Yosemite 10.10.3 python: 2.6.6

error list

--freetype cannot be built when installing --Library ImportError --Runtime Error --The graph closes in an instant (not an error)

1. Pip installation errors and remedies

If you install with pip install matplotlib

=================================================== The following required packages can not be built: freetype Command "python setup.py egg_info" failed with error code 1

And stop with the error. Search, it seems to be a fixed bug now.

For a quick install, enter freetype with brew install freetype as shown in the error message.

Then run pip install matplotlib again and the installation will complete without any problems.

2. Errors and workarounds when importing in code

When I try to import and run matplotlib in my code

ImportError:dlopen(~): Library not loaded: Reason: image not found

And stop with an error. It seems that the dynamic link library cannot be loaded, and when I see the message, it seems that libpng and freetype are not working.

So once pip uninstall matplotlib After doing brew reinstall libpng --universal brew reinstall freetype --universal Install the dll again with.

But again, it stopped with the following error:

Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/man/man5/png.5 /usr/local/share/man/man5 is not writable. You can try again using: brew link libpng

It seems that writing is not possible due to permission problems, so refer to here sudo chown -R $(whoami) /usr/local/lib/pkgconfig sudo chown -R $(whoami) /usr/local/share/man/man5 Change the owner with. Do brew link libpng again and succeed. brew reinstall freetype --universal succeeded without any problem. After that, run pip install matplotlib again to resolve the import error.

3. Run-time errors and remedies

You can now import, but when you run it

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.

Stops with the error. The solution is detailed in Post here ~/.matplotlib Create a matplotlibrc file in backend : TkAgg It seems that you can specify a backend other than macosx like this.

With the above, the graph can be drawn at last.

4. Graph drawing ends in an instant

It's not an error, but I was a little addicted to it without knowing it.

import matplotlib.pyplot as plt And if you import, to the part where you want to stop drawing plt.show() It is OK if you write.

Recommended Posts

Until you install and run matplotlib
Until you install Caffe and run the sample
Until you install Gauge and run the official sample
Until you install MySQL-python
Until you install Python with pythonbrew and run Flask on a WSGI server
Install and run dropbox on Ubuntu 20.04
Until you can install blender and run it with python for the time being
Until you run python with apache
Until you build the environment with ABCI and run MaskTrack RCNN
Until you install Arch Linux on VMware
Until you install Apache and Tomcat on Linux (CentOS) and deploy Java apps
Install matplotlib and display graph on Jupyter Notebook
Install and run Python3.5 + NumPy + SciPy on Windows 10
Until you run the changefinder sample in python
Install pyenv and pyenv-virtualenv
Install and configure KVM
Until you install Anaconda for data analysis on your Mac and launch the IDE
Install Docker on Arch Linux and run it remotely
Until you run server Django in Visual Studio Code
Until you install TensorFlow-GPU with pip in Windows environment
Until you create a machine learning environment with Python on Windows 7 and run it
matplotlib this and that
Until you create Python Virtualenv on Windows and launch Jupyter
Until you can install your own Python library with pip
Try and learn iptables, until you can browse the web
Asynchronously run matplotlib interactive mode
Install Python and Flask (Windows 10)
matplotlib gallery and color map
Install Python 3.7 and Django 3.0 (CentOS)
How to install OpenCV on Cloud9 and run it in Python
[Work memo] Until matplotlib and numpy are installed in Amazon Linux
When you run diff in python and want both returncode and output
[TensorFlow] If you want to run TensorBoard, install it with pip
[xgboost error] Cannot find XGBoost Libarary in the candicate path, did you install compilers and run build.sh in root path