# 使用matplotlib时fontList.py3k.cache not found问题解决

使用matplotlib时fontList.py3k.cache not found问题解决

runfile('E:/rqalpha-master/tests/run_func_test.py', wdir='E:/rqalpha-master/tests')
[2018-07-30 15:43:05.087574] DEBUG: basic_system_log: 
{'base': {'accounts': {'STOCK': 100000.0},
          'benchmark': '000300.XSHG',
          'data_bundle_path': 'C:\\Users\\win10/.rqalpha\\bundle',
          'end_date': datetime.date(2016, 12, 1),
          'frequency': '1d',
          'init_positions': [],
          'margin_multiplier': 1,
          'persist': False,
          'persist_mode': PERSIST_MODE.REAL_TIME,
          'resume_mode': False,
          'round_price': False,
          'run_type': RUN_TYPE.BACKTEST,
          'source_code': None,
          'start_date': datetime.date(2016, 6, 1),
          'strategy_file': 'strategy.py'},
 'extra': {'context_vars': None,
           'enable_profiler': False,
           'force_run_init_when_pt_resume': False,
           'is_hold': False,
           'locale': 'zh_Hans_CN',
           'log_level': 'verbose',
           'logger': [],
           'user_log_disabled': False,
           'user_system_log_disabled': False},
 'mod': {'sys_accounts': {'enabled': True},
         'sys_analyser': {'enabled': True, 'plot': True},
         'sys_booking': {'enabled': False},
         'sys_funcat': {'enabled': False},
         'sys_incremental': {'enabled': False},
         'sys_progress': {'enabled': True},
         'sys_risk': {'enabled': True},
         'sys_simulation': {'enabled': True},
         'sys_stock_realtime': {'enabled': False}},
 'validator': {'close_amount': True},
 'version': '0.1.6',
 'whitelist': ['base', 'extra', 'validator', 'mod']}
[2018-07-30 15:43:05.095064] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_simulation
[2018-07-30 15:43:05.100077] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_progress
[2018-07-30 15:43:05.105617] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_accounts
[2018-07-30 15:43:05.111107] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_analyser
[2018-07-30 15:43:05.116121] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_risk
[2018-07-30 15:43:05.121133] DEBUG: basic_system_log: mod start_up [START] sys_simulation
[2018-07-30 15:43:05.127150] DEBUG: basic_system_log: mod start_up [END]   sys_simulation
[2018-07-30 15:43:05.131661] DEBUG: basic_system_log: mod start_up [START] sys_progress
[2018-07-30 15:43:05.137176] DEBUG: basic_system_log: mod start_up [END]   sys_progress
[2018-07-30 15:43:05.142189] DEBUG: basic_system_log: mod start_up [START] sys_accounts
[2018-07-30 15:43:05.147231] DEBUG: basic_system_log: mod start_up [END]   sys_accounts
[2018-07-30 15:43:05.152217] DEBUG: basic_system_log: mod start_up [START] sys_analyser
[2018-07-30 15:43:05.157230] DEBUG: basic_system_log: mod start_up [END]   sys_analyser
[2018-07-30 15:43:05.165752] DEBUG: basic_system_log: mod start_up [START] sys_risk
[2018-07-30 15:43:05.172771] DEBUG: basic_system_log: mod start_up [END]   sys_risk
2016-06-01 INFO init
----------------------------------------------------------------------------------------
[2018-07-30 15:43:05.751400] DEBUG: basic_system_log: mod tear_down [START] sys_risk
[2018-07-30 15:43:05.756885] DEBUG: basic_system_log: mod tear_down [END]   sys_risk
[2018-07-30 15:43:05.763403] DEBUG: basic_system_log: mod tear_down [START] sys_analyser
[2018-07-30 15:43:05.793983] ERROR: system_log: tear down fail for sys_analyser
Traceback (most recent call last):
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 1413, in 
    fontManager = pickle_load(_fmcache)
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 964, in pickle_load
    with open(filename, 'rb') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\win10\\.matplotlib\\fontList.py3k.cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda3.5-64\lib\site-packages\rqalpha\mod\__init__.py", line 77, in tear_down
    ret = self._mod_dict[mod_name].tear_down(*args)
  File "C:\Anaconda3.5-64\lib\site-packages\rqalpha\mod\rqalpha_mod_sys_analyser\mod.py", line 277, in tear_down
    plot_result(result_dict, self._mod_config.plot, self._mod_config.plot_save_file)
  File "C:\Anaconda3.5-64\lib\site-packages\rqalpha\mod\rqalpha_mod_sys_analyser\plot.py", line 24, in plot_result
    from matplotlib import rcParams, gridspec, ticker, image as mpimg, pyplot as plt
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\pyplot.py", line 29, in 
    import matplotlib.colorbar
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\colorbar.py", line 34, in 
    import matplotlib.collections as collections
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\collections.py", line 27, in 
    import matplotlib.backend_bases as backend_bases
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\backend_bases.py", line 62, in 
    import matplotlib.textpath as textpath
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\textpath.py", line 15, in 
    import matplotlib.font_manager as font_manager
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 1421, in 
    _rebuild()
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 1406, in _rebuild
    fontManager = FontManager()
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 1044, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 313, in findSystemFonts
    for f in win32InstalledFonts(fontdir):
  File "C:\Anaconda3.5-64\lib\site-packages\matplotlib\font_manager.py", line 231, in win32InstalledFonts
    direc = os.path.abspath(direc).lower()
  File "C:\Anaconda3.5-64\lib\ntpath.py", line 535, in abspath
    path = _getfullpathname(path)
ValueError: _getfullpathname: embedded null character
[2018-07-30 15:43:05.800022] DEBUG: basic_system_log: mod tear_down [START] sys_accounts
[2018-07-30 15:43:05.803509] DEBUG: basic_system_log: mod tear_down [END]   sys_accounts
[2018-07-30 15:43:05.806516] DEBUG: basic_system_log: mod tear_down [START] sys_progress
[2018-07-30 15:43:05.809525] DEBUG: basic_system_log: mod tear_down [END]   sys_progress
[2018-07-30 15:43:05.813034] DEBUG: basic_system_log: mod tear_down [START] sys_simulation
[2018-07-30 15:43:05.815540] DEBUG: basic_system_log: mod tear_down [END]   sys_simulation
[2018-07-30 15:43:05.818548] DEBUG: system_log: 策略运行成功,正常退出

使用matplotlib时候就出现了fontList.py3k.cache not found
发现是读取地址的bug,也是坑爹的
如果遇到这个问题需要将matplotlib目录下的font_manager.py第231的改为direc = direc.split(‘\0’,1)[0]就可以了

更多量化学习资源

介绍.png
扫上方二维码,关注公众账号 量化投资学院 ,获取下列免费资源
- 回复“热点研报”,获取近年热点券商金融工程研究报告
- 回复“Python3”,获取Python免费学习教程
* 更多福利请点击此链接

关注StudyQuant

  • 课程
    –量化投资与数据分析实战
    –量化投资与数字货币实战
    –免费Python及量化投资公开课

  • 知乎

  • 简书
  • 公众号

你可能感兴趣的:(Python量化投资,bug修复)