2017-06-21 53 views
0

導入matplotlib時,我得到這個引用。當使用python導入matplotlib.pyplot時,權限被拒絕

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' 

我該如何解決?

+0

如果突出顯示所有回溯並選擇括號,可以更好地進行格式化,這樣會更容易閱讀。我試圖編輯它,但我得到一個錯誤。 – mauve

回答

1

看起來執行該進程的用戶無權訪問文件/Library/Fonts/WarnockPro-Subh.otf或其父目錄之一。

您是否試過chown該文件或目錄?

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

即時通訊仍然是新的python,但我試圖chown它,我得到errno 1操作不允許 –

+0

作爲具有sudo特權的用戶。 –