qq_38991062 2021-09-16 10:51 采纳率: 0%
浏览 142

在anaconda的jupyter notebook编译器中引用matplotlib.pyplot报错 Python版本是 3.8.8

在anaconda下的jupyter notebook(TensorFlow)环境下引用import matplotlib.pyplot as plt报错,但是如果是import matplotlib as plt就没有问题,找半天了不知道是啥原因。
而且报错提示好长,以下是报错提示:

FileNotFoundError                         Traceback (most recent call last)
~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in <module>()
   1428         try:
-> 1429             fontManager = pickle_load(_fmcache)
   1430             if (not hasattr(fontManager, '_version') or

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in pickle_load(filename)
    964     """
--> 965     with open(filename, 'rb') as fh:
    966         data = pickle.load(fh)

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\ASUS\\.matplotlib\\fontList.py3k.cache'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-1-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt

~\anaconda3\envs\tensorflow\lib\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

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\colorbar.py in <module>()
     34 import matplotlib.collections as collections
     35 import matplotlib.colors as colors
---> 36 import matplotlib.contour as contour
     37 import matplotlib.cm as cm
     38 import matplotlib.gridspec as gridspec

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\contour.py in <module>()
     20 import matplotlib.colors as colors
     21 import matplotlib.collections as mcoll
---> 22 import matplotlib.font_manager as font_manager
     23 import matplotlib.text as text
     24 import matplotlib.cbook as cbook

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in <module>()
   1437             raise
   1438         except:
-> 1439             _rebuild()
   1440     else:
   1441         _rebuild()

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in _rebuild()
   1416         global fontManager
   1417 
-> 1418         fontManager = FontManager()
   1419 
   1420         if _fmcache:

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in __init__(self, size, weight)
   1051         #  Load TrueType fonts and create font dictionary.
   1052 
-> 1053         self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   1054         self.defaultFamily = {
   1055             'ttf': 'DejaVu Sans',

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in findSystemFonts(fontpaths, fontext)
    323             fontpaths = [fontdir]
    324             # now get all installed fonts directly...
--> 325             for f in win32InstalledFonts(fontdir):
    326                 base, ext = os.path.splitext(f)
    327                 if len(ext)>1 and ext[1:].lower() in fontexts:

~\anaconda3\envs\tensorflow\lib\site-packages\matplotlib\font_manager.py in win32InstalledFonts(directory, fontext)
    239                     if not os.path.dirname(direc):
    240                         direc = os.path.join(directory, direc)
--> 241                     direc = os.path.abspath(direc).lower()
    242                     if os.path.splitext(direc)[1][1:] in fontext:
    243                         items[direc] = 1

~\anaconda3\envs\tensorflow\lib\ntpath.py in abspath(path)
    533         if path: # Empty path must return current working directory.
    534             try:
--> 535                 path = _getfullpathname(path)
    536             except OSError:
    537                 pass # Bad path - return unchanged.

ValueError: _getfullpathname: embedded null character

请各位帮忙看看咋改,好像它这个报错还不止一个错误

  • 写回答

2条回答 默认 最新

  • CSDN专家-Time 2021-09-16 10:53
    关注

    from matplotlib import pyplot as plt

    评论

报告相同问题?

问题事件

  • 创建了问题 9月16日

悬赏问题

  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 怎么在stm32门禁成品上增加记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号