Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating anaconda & python 'import matplotlib.pyplot as plt' does not work anymore

I'm having trouble to use the command

import matplotlib.pyplot as plt

I used my scripts before but they don't work anymore since I have updated my anaconda using

conda -update all

I receive a long error message but I do not really understand what's the issue, see attached code. Anybody has an idea how to fix it? I have even de-installed anaconda and re-installed it but it hasn't fixed it? Also I updated only the marplotlib using condo but it did not help. Any suggestions?

run transform.py
/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273:UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Users/tfridrich/computing/Log_spectral_analysis/test01/transform.py in <module>()
      6 import scipy.fftpack
      7 #import matplotlib as plt
----> 8 import matplotlib.pyplot as plt
      9 from las import LASReader
     10 import checknumber

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
     27 from cycler import cycler
     28 import matplotlib
---> 29 import matplotlib.colorbar
     30 from matplotlib import style
     31 from matplotlib import _pylab_helpers, interactive

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
     32 import matplotlib.artist as martist
     33 import matplotlib.cbook as cbook
---> 34 import matplotlib.collections as collections
     35 import matplotlib.colors as colors
     36 import matplotlib.contour as contour

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
     25 import matplotlib.artist as artist
     26 from matplotlib.artist import allow_rasterization
---> 27 import matplotlib.backend_bases as backend_bases
     28 import matplotlib.path as mpath
     29 from matplotlib import _path

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
     60 
     61 import matplotlib.tight_bbox as tight_bbox
---> 62 import matplotlib.textpath as textpath
     63 from matplotlib.path import Path
     64 from matplotlib.cbook import mplDeprecation, warn_deprecated

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
     13 from matplotlib.path import Path
     14 from matplotlib import rcParams
---> 15 import matplotlib.font_manager as font_manager
     16 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
     17 from matplotlib.ft2font import LOAD_TARGET_LIGHT

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
   1419                 verbose.report("Using fontManager instance from %s" % _fmcache)
   1420         except:
-> 1421             _rebuild()
   1422     else:
   1423         _rebuild()

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in _rebuild()
   1404     def _rebuild():
   1405         global fontManager
-> 1406         fontManager = FontManager()
   1407         if _fmcache:
   1408             pickle_dump(fontManager, _fmcache)

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
   1042         #  Load TrueType fonts and create font dictionary.
   1043 
-> 1044         self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   1045         self.defaultFamily = {
   1046             'ttf': 'Bitstream Vera Sans',

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in findSystemFonts(fontpaths, fontext)
    322                     fontfiles[f] = 1
    323 
--> 324             for f in get_fontconfig_fonts(fontext):
    325                 fontfiles[f] = 1
    326 

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in get_fontconfig_fonts(fontext)
    274         pipe = subprocess.Popen(['fc-list', '--format=%{file}\\n'],
    275                                 stdout=subprocess.PIPE,
--> 276                                 stderr=subprocess.PIPE)
    277         output = pipe.communicate()[0]
    278     except (OSError, IOError):

/Users/tfridrich/anaconda/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    708                                 p2cread, p2cwrite,
    709                                 c2pread, c2pwrite,
--> 710                                 errread, errwrite)
    711         except Exception:
    712             # Preserve original exception in case os.close raises.

/Users/tfridrich/anaconda/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
   1332                     if e.errno != errno.ECHILD:
   1333                         raise
-> 1334                 child_exception = pickle.loads(data)
   1335                 raise child_exception
   1336 

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in loads(str)
   1386 def loads(str):
   1387     file = StringIO(str)
-> 1388     return Unpickler(file).load()
   1389 
   1390 # Doctest

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in load(self)
    862             while 1:
    863                 key = read(1)
--> 864                 dispatch[key](self)
    865         except _Stop, stopinst:
    866             return stopinst.value

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in load_string(self)
    970             if rep.startswith(q):
    971                 if len(rep) < 2 or not rep.endswith(q):
--> 972                     raise ValueError, "insecure string pickle"
    973                 rep = rep[len(q):-len(q)]
    974                 break

ValueError: insecure string pickle
like image 383
tfridrich Avatar asked Jan 22 '16 03:01

tfridrich


1 Answers

I had the same problem after updating OS X to El Capitan. After lots of searching I found that X11 is no longer included with OS X (see https://support.apple.com/en-us/HT201341) and that you need to install XQuartz as a replacement (see http://www.xquartz.org/). After this I was able to successfully import matplotlib.pyplot.

like image 55
Daniel Cimring Avatar answered Oct 16 '22 03:10

Daniel Cimring