** "First pattern recognition" reading party ** is about to end, so I talked about what to read in the next series, "Practical Computer Vision ”has appeared.
It's just stored in my house, so I thought I'd pull it out and read it for a while, but I was addicted to creating the environment. And for a reason that doesn't really matter. Pathetic ...
Make a note so that no one will follow the same rut.
I can install it by pip install PIL without thinking about anything, but when I read the jpeg file and try to show it with pylab, I get the following error.
IOError: decoder jpeg not available
I was told that there is no jpeg decoder, so when I googled it, it seems that libjpeg-dev needs to be installed. However, when I sudo apt-get install libjpeg-dev, I was angry with "I already have it!".
When libjpeg-dev is installed with apt, libjpeg.so is created under / usr / lib / x86_64-linux-gnu /, but it seems that this folder is not seen when installing PIL with pip.
So, let's put a symbolic link where you can see it from pip.
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
After linking, I reinstalled PIL and it worked fine.
http://atasatamatara.hatenablog.jp/entry/20120723/1343044059
matplotlib can also be entered with pip. Numpy is also included because of the dependency.
However, nothing is displayed when pylab.show () is executed. I don't even get an error. What is this? ?? ??
After investigating, it seems that the backend for screen display is set appropriately. As for where to set it, there is a file called matplotlibrc. The following command will tell you the location.
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
matplotlibrc
backend : agg
With a backend called agg, you can write to a file, but you can't open a window and display it on the screen.
Actually, matplotlib is also included in system-wide python, but when I look at that matplotlibrc, the backend is Tkagg. It looks like you're using Tkinter.
So I will rewrite from agg to Tkagg. Then, the following error came to appear this time.
No module named _tkagg
It seems that the file _tkagg.py is not generated when compiling matplotlib. To solve this, you need to install tk-dev.
sudo apt-get install tk-dev
This time it will be under / usr / lib, so there is no need to put a link. If you install matplotlib after installing tk-dev, you can do it.
I wrote it in the order I tried various things by groping, but it should be set up like this.
sudo apt-get install libjpeg tk-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
pip install PIL
pip install matplotlib
vim /path/to/your/matplotlibrc
###Rewrite backend to Tkapp
By the way, if you google, the information will come out as it is, but because I decided that "If it is a system-wide matplotlib, it will be displayed properly with tk, so there is no reason why tk-dev is not included" and did not confirm it. I'm addicted to it.
I don't remember how it happened, but maybe when I put it in system wide, it was apt, and since I put it in binary, _tkagg was included even without tk-dev ...
Recommended Posts