Skip to content Skip to sidebar Skip to footer

Cannot Import Markdown Because Of COMMAND_LINE_LOGGING_LEVEL

I've got a weird error where I can import markdown in Python, and I can import markdown in python inside the Django runserver, but I get the following when trying to import markdow

Solution 1:

I fixed this error by removing the .py extension from markdown.py in whatever/bin. This apparently prevented it from importing itself instead of the markdown module in site-packages.


Solution 2:

Gunicorn, for reasons I don't understand yet, adds the virtualenv/bin directory to the sys.path. Markdown installs a markdown.py into that bin directory. That markdown.py tries to import COMMAND_LINE_LOGGING_LEVEL from markdown the library. This results in a circular failure.

I don't know why Gunicorn does this, and probably it shouldn't. My convenience fix is to add the following to the server's local_settings.py

import sys
for i, path in enumerate(sys.path):
    if path.endswith('bin'):
        del sys.path[i]

Post a Comment for "Cannot Import Markdown Because Of COMMAND_LINE_LOGGING_LEVEL"