【问题标题】:Permission denied when importing matplotlib.pyplot using python使用 python 导入 matplotlib.pyplot 时权限被拒绝
【发布时间】:2017-11-24 13:50:13
【问题描述】:

我在导入 matplotlib 时收到此引用。

import matplotlib.pyplot as plt
/Users/ny/anaconda/lib/python3.5/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.')
Traceback (most recent call last):

  File "<ipython-input-18-eff513f636fd>", line 1, in <module>
    import matplotlib.pyplot as plt

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/colorbar.py", line 34, in <module>
    import matplotlib.collections as collections

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/collections.py", line 27, in <module>
    import matplotlib.backend_bases as backend_bases

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/backend_bases.py", line 62, in <module>
    import matplotlib.textpath as textpath

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/textpath.py", line 15, in <module>
    import matplotlib.font_manager as font_manager

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1421, in <module>
    _rebuild()

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1406, in _rebuild
    fontManager = FontManager()

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1059, in __init__
    self.ttflist = createFontList(self.ttffiles)

  File "/Users/ny/anaconda/lib/python3.5/site-packages/matplotlib/font_manager.py", line 581, in createFontList
    font = ft2font.FT2Font(fpath)

PermissionError: [Errno 13] Permission denied: '/Library/Fonts/WarnockPro-Subh.otf'

我该如何解决?

【问题讨论】:

  • 如果您突出显示所有回溯然后选择括号,这将更容易阅读,这样会更好地格式化它。我尝试对其进行编辑,但出现错误。

标签: python matplotlib anaconda spyder


【解决方案1】:

执行该进程的用户似乎无权访问文件/Library/Fonts/WarnockPro-Subh.otf 或其父目录之一。

你试过chown文件或目录吗?

chown user_name file
chown user_name folder
chown -R user_name folder #recursive

【讨论】:

  • 我还是 python 新手,但我尝试 chown 它并且我得到 Errno 1 operation not allowed
  • 以具有 sudo 权限的用户身份进行操作。
猜你喜欢
  • 1970-01-01
  • 2016-01-19
  • 2015-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-28
  • 1970-01-01
相关资源
最近更新 更多