When I installed matplotlib and tried to draw a graph, it got stuck more than I expected, so make a note.
Own machine: Yosemite 10.10.3 python: 2.6.6
--freetype cannot be built when installing --Library ImportError --Runtime Error --The graph closes in an instant (not an error)
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.
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.
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.
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