Repository navigation
Closed
Milestone
Description
A colleague ran into the following error after installing a fresh copy of Matplotlib on OSX 10.11:
$ python -c 'import matplotlib.pyplot'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 62, in <module>
import matplotlib.textpath as textpath
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/textpath.py", line 15, in <module>
import matplotlib.font_manager as font_manager
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1420, in <module>
_rebuild()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1405, in _rebuild
fontManager = FontManager()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1043, in __init__
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 323, in findSystemFonts
for f in get_fontconfig_fonts(fontext):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 275, in get_fontconfig_fonts
stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1334, in _execute_child
child_exception = pickle.loads(data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1382, in loads
return Unpickler(file).load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 966, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle
Not surprisingly, the problem turns out to be in get_fontconfig_fonts where the command subprocess.Popen(['fc-list', '--format=%{file}\\n'], ...) returns a ValueError instead of the expected OSError, IOError and so the routine tries to load a pickle from the error message text and fails. fc-list does not exist on my colleague's system.
Activity
mdboom commentedon Nov 3, 2015
Probably the same as #5314.
I think your assessment isn't quite right though.
subprocess.Popen(['fc-list', '--format=%{file}\\n'], ...)isn't raising aValueErrorthat is causing matplotlib to try to load a pickle.subprocessitself is trying to load a pickle containing an exception from a child process, and that pickle is broken, probably due to the pipe not getting properly flushed.There's something fishy here, but I don't think matplotlib catching a ValueError is the right thing to do. According to the docs, that should only be raised when invalid arguments are passed to
Popen, which they aren't here.I found other reports of similar bugs: this seems to be the new symptom for "file not found" on OSX 10.11, which is definitely broken behavior:
ytdl-org/youtube-dl#6840
healpy/healpy#284
Also, for fun:
https://i.imgur.com/To3DQ6J.jpg
Does:
also give the same error? If so, definitely a bug that should be reported to CPython and/or Apple.
tacaswell commentedon Nov 3, 2015
That is an awesome cartoon!
mdboom commentedon Nov 3, 2015
I found it on the Python bugtracker. https://bugs.python.org/issue18172
matthew-brett commentedon Nov 3, 2015
Further feedback from my 10.11 source:
mdboom commentedon Nov 3, 2015
Great. I'd say it's definitely a bug in Python 2.7.10 and/or an incompatiblity between how Apple builds Python 2.7.10 and El Capitain. I'd report this to CPython and/or Apple. I'd file the report myself, but since I don't have El Capitain to reproduce on, I'm afraid I won't be of much use.
jenshnielsen commentedon Nov 3, 2015
I can't reproduce it in any way using neither system python nor python 2.7 or 3.5 from homebrew on 10.11.1. Could it be fixed in the 10.11.1 update?
matthew-brett commentedon Nov 4, 2015
@jenshnielsen - is it possible that you have
fc-listinstalled on your system? In that case I think you would not get the error.jenshnielsen commentedon Nov 4, 2015
Yes I have font-config installed. What I meant was that I can't reproduce the issue with a non existing command such as 'foo' with either python version i.e. running
p = subprocess.Popen(['foo'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)raises a FileNotFoundError as expected.
matthew-brett commentedon Nov 4, 2015
Ah - sorry for my confusion. My colleague also has 10.11.1. Can you think of any other explanation for the difference.
jenshnielsen commentedon Nov 4, 2015
Just a shot in the dark but could it be something like a non ascii username/path
matthew-brett commentedon Nov 5, 2015
I don't think that's the case for my colleague's machine. We just upgraded a machine, and don't get the failure either.
matthew-brett commentedon Nov 8, 2015
Nicholas Angelides is my colleague with this bug - we sat down with his computer for a few minutes.
This expanded the confusion. We replicated the behavior above, both on his account and a new
Testaccount, with system Python. Then we rebooted the machine and got the expected behavior on his account and the newTestaccount. I'm a bit lost for ways to proceed. Any suggestions?tacaswell commentedon Nov 11, 2015
Hurrah, a Heisenbug!
mariusae commentedon Dec 1, 2015
It appears python is assuming that a single read() call will read all available data (until EOF). That is not so. This should fix it:
tacaswell commentedon Dec 1, 2015
That needs to be reported upstream, we are not going to ship a monkey patch to a core library.
mariusae commentedon Dec 1, 2015
Yep, wasn't suggesting that... just giving people a workaround until it is resolved.
yan12125 commentedon Jan 11, 2016
Seems nobody has reported it to Python. Here it is: http://bugs.python.org/issue26083.
gpshead commentedon Jan 11, 2016
A good workaround for matplotlib would be to use subprocess32 instead of subprocess when running on Python 2. It is better in too many ways to list here (and acts as a drop in replacement). The upstream issue has been fixed in 2.7.
But I wouldn't expect Apple to fix anything in a timely manner. Pro tip: Build and install your own Python, never use the one shipped by your OS distro.
ludoleg commentedon Feb 6, 2016
I don't see the 2.7.12 release out yet . What is the best way to work around this issue to run matplotlib on El Capitan?
actongorton commentedon Feb 16, 2016
I'm also having this issue, and my Python is installed through HomeBrew.
Why not go with @gpshead advice instead of waiting for a fix from Python?
tacaswell commentedon Apr 29, 2016
@acer9997 pull requests are always welcome.
QuLogic commentedon Oct 22, 2016
2.0 will require
subprocess32to work around this bug (see #6576.)