Matplotlib output does not appear in string format on IPython laptop, despite the built-in --pylab option

I am running IPython Notebook and the matplotlib output does not appear on the line, but instead:

<matplotlib.figure.Figure at 0x113035310> 

Here is the code:

 from pylab import * X = np.linspace(-np.pi, np.pi, 256,endpoint=True) C,S = np.cos(X), np.sin(X) plot(X,C) plot(X,S) show() 

The laptop was started with --pylab = inline, and when I check it, it looks right:

enter image description here

This is with IPython 1.1.0. When I try to do this with% pylab inline, I get similar results:

enter image description here

What else could be the reason that the chart does not appear on the line?

+6
source share
2 answers

It turns out that the built-in display (and perhaps even the generation of the image in the first place) failed because matplotlib was unable to load the Vera.ttf font Vera.ttf . He tried to download this file from the wrong file system location, which was not available for a process that was running in the OS X sandbox.

10/29/13 11:59:02.000 PM kernel[0]: Sandbox: python(24173) deny file-read-data $HOME/Library/Developer/Xcode/DerivedData/IPython_Notebook-adcshxaaibpeztbztvthgauvufsx/Build/Products/Debug/IPython Notebook.app/Contents/Resources/virtualenv/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

The process ran from this location:

$HOME/Library/Developer/Xcode/DerivedData/IPython_Notebook-adcshxaaibpeztbztvthgauvufsx/Build/Products/Release/IPython Notebook.app

("Debugging" and "Release")

After I damaged the Debug location and restarted the application, the sandbox message disappeared and the built-in graph started working. When I copied the application package to another location and launched it from there, it again failed. A stack trace in the sandbox violation report indicates that FreeType is trying to download the font from the old location:

 0 libsystem_kernel.dylib 0x00007fff9054f5da __open + 10 1 libfreetype.dylib 0x000000010b789214 FT_Stream_New + 260 2 libfreetype.dylib 0x000000010b789e00 FT_Open_Face + 144 3 libfreetype.dylib 0x000000010b789d5e FT_New_Face + 46 4 ft2font.so 0x000000010b7259f0 FT2Font::FT2Font(Py::PythonClassInstance*, Py::Tuple&, Py::Dict&) + 698 5 ft2font.so 0x000000010b735fa6 Py::PythonClass<FT2Font>::extension_object_init(_object*, _object*, _object*) + 116 

Some research has shown that matplotlib supports the fontList.cache file, which ends in the container directory for the application sandbox. After moving the application package, the paths in this cache file are invalid / inaccessible. I added code to my application to delete this cache file at startup.

So this is not an IPython problem, but I thought I would post it if it helps someone who will also introduce the laptop into the OS X app sandbox in the future.

+7
source

Try %matplotlib inline, I think this is just a default problem.

-4
source

Source: https://habr.com/ru/post/957007/


All Articles