Want to use Pygments with Jekyll, but can’t get passed the
Failed to get header (MentosError) exception?
You’ve read the documentation. You’ve run
bundle install, you’ve got Python installed, and you double-checked that all of your files are named appropriately. Everything was working until you added this to your
That’s when things blew up:
Configuration from /home/chris/website/_config.yml Building site: /home/chris/website -> /home/chris/website/_site ... /home/chris/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:357:in `rescue in get_header': Failed to get header. (MentosError) from /home/chris/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:338:in `get_header' from /home/chris/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:235:in `block in mentos'
Turns out, there’s one more step. Pygments requires Python 2.x and you’re probably using 3.x by default.
In may case, changing the system default wouldn’t work because I have dependencies on 3.x elsewhere in my system. The quick and dirty workaround is to set Python 2 as the default for your shell while you’re messing with Jekyll:
which python2 # => /usr/bin/python2 ln -s /usr/bin/python2 ~/bin/python
Or, in compact form (if you know there is a
python2 binary in your
ln -s `which python2` ~/bin/python