Repository: xonsh/xonsh

Issue:
Exception on startup after updating to 0.6.7 (pygments_cache)
After updating to 0.6.7 (form AUR) I get the following exception on startup.

```python
pygments cache not found, building...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 20794, in main
    return main_xonsh(args)
  File "/usr/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 20820, in main_xonsh
    shell.shell.cmdloop()
  File "/usr/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 153, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
  File "/usr/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 82, in singleline
    self.styler.style_name = env.get('XONSH_COLOR_STYLE')
  File "/usr/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 14930, in styler
    self._styler = XonshStyle(env.get('XONSH_COLOR_STYLE'))
  File "/usr/lib/python3.6/site-packages/xonsh/pyghooks.py", line 410, in __init__
    self.style_name = style_name
  File "/usr/lib/python3.6/site-packages/xonsh/pyghooks.py", line 434, in style_name
    self._smap = get_style_by_name(value)().styles.copy()
  File "/usr/lib/python3.6/site-packages/xonsh/pygments_cache.py", line 377, in get_style_by_name
    load_or_build()
  File "/usr/lib/python3.6/site-packages/xonsh/pygments_cache.py", line 279, in load_or_build
    CACHE = build_cache()
  File "/usr/lib/python3.6/site-packages/xonsh/pygments_cache.py", line 227, in build_cache
    cache['lexers'] = _discover_lexers()
  File "/usr/lib/python3.6/site-packages/xonsh/pygments_cache.py", line 103, in _discover_lexers
    for longname, aliases, filenames, mimetypes in get_all_lexers():
  File "/usr/lib/python3.6/site-packages/pygments/lexers/__init__.py", line 53, in get_all_lexers
    for lexer in find_plugin_lexers():
  File "/usr/lib/python3.6/site-packages/pygments/plugin.py", line 52, in find_plugin_lexers
    for entrypoint in iter_entry_points(LEXER_ENTRY_POINT):
  File "/usr/lib/python3.6/site-packages/pygments/plugin.py", line 49, in iter_entry_points
    return pkg_resources.iter_entry_points(group_name)
TypeError: 'NoneType' object is not callable
Xonsh encountered an issue during launch
```


Discussion:
I downgraded Pygments from 2.2.0 to 2.1.3 and now I don't get the exception.
Thanks for reporting, @nilehmann!  
I'm on pygments 2.2.0 on current master and can't seem to reproduce the error.
Thanks for reporting @nilehmann! I have seen this on one of my machines once. It seems to happens if the pygments cache file does not exist on xonsh startup.  That is interesting that downgrading to pygments 2.1.3 fixes it.
I upgraded Pygments back to 2.2.0 and everything appears to be working correctly, so probably as  @scopatz commented, after successfully creating the cache file with 2.1.3 I can use 2.2.0 without problems.
haha well that is annoying!

Resolving patch:
diff --git a/xonsh/ptk/__init__.py b/xonsh/ptk/__init__.py
--- a/xonsh/ptk/__init__.py
+++ b/xonsh/ptk/__init__.py
@@ -1,5 +0,0 @@
-# must come before ptk / pygments imports
-from xonsh.lazyasd import load_module_in_background
-
-load_module_in_background('pkg_resources', debug='XONSH_DEBUG',
-                          replacements={'pygments.plugin': 'pkg_resources'})


Test patch: