[Django]-Cannot import markdown because of COMMAND_LINE_LOGGING_LEVEL

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]

2👍

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.

👤tkb

Leave a comment