gpt4 book ai didi

python - 更新 anaconda 和 python 后 'import matplotlib.pyplot as plt' 不再工作

转载 作者:太空狗 更新时间:2023-10-29 21:54:44 27 4
gpt4 key购买 nike

我在使用命令时遇到问题

import matplotlib.pyplot as plt

我以前用过我的脚本,但自从我更新了我的 anaconda 之后它们就不再工作了

conda -update all

我收到一条很长的错误消息,但我不太明白问题出在哪里,请参阅附加代码。有人知道如何解决它吗?我什至卸载了 anaconda 并重新安装了它,但还没有修复它?我还使用 condo 仅更新了 marplotlib,但没有帮助。有什么建议吗?

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

最佳答案

将 OS X 更新到 El Capitan 后,我遇到了同样的问题。经过大量搜索后,我发现 X11 不再包含在 OS X 中(参见 https://support.apple.com/en-us/HT201341),您需要安装 XQuartz 作为替代(参见 http://www.xquartz.org/)。在此之后,我能够成功导入 matplotlib.pyplot。

关于python - 更新 anaconda 和 python 后 'import matplotlib.pyplot as plt' 不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34938533/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com