Monday, July 21, 2014

Vimrepress python-markdown error on Mac OSX and the fix

I am trying to use the vimrepress addon for publish blog posts from vim. It requires a python module called Markdown, presumably capable of translating markdown into html. It can be installed by:

pip install Markdown

But after that vimrepress still complains that “python-markdown is required”. After some thinking, I figured it must be having some trouble finding out where the module is, why not give him a tip? So I inserted a line:

sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")

in the blog.vim file. Now it looks somewhat like this:

import vim
import urllib
import xmlrpclib
import re
import os
import mimetypes
import webbrowser
import tempfile
import sys
from ConfigParser import SafeConfigParser

sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")

try:
    import markdown
except ImportError:
    try:
        import markdown2 as markdown
    except ImportError:
        class markdown_stub(object):
            def markdown(self, n):
                raise VimPressException("Twice import error. The package python-markdown is "
                        "required and is either not present or not properly "
                        "installed.")

        markdown = markdown_stub()

And indeed the problem is solved!

0 comments: