This one I hope is quite a simple issue - but may be made a little more complicated by the fact that I am using the Divio Django cms service.
I'm using Python 2.7.11 and Django 1.11.1 for all the egg heads out there that care about these things.
Essentially my app is failing to find the Markdown package:
import markdown
or
from markdown import markdown
or
from markdown import *
or even (this is getting fancy)
try:
from markdown import markdown
except ImportError:
class MarkdownNotFound(Exception):
def __str__(self):
return "Uuuugh, why isn't this simple thing working"
raise MarkdownNotFound
All will give the general error:
ImportError: No module named markdown
(Obviously, all with slightly different wording).
Uuuugh, why isn't this simple thing working?
I've pip installed
markdown until the cows come home...so it's there. Just can't be found by my Django project.
import datetime
works without issue. Is there something I am missing which is quite simple or, if not, are there any alternatives to the markdown module in Django that actually work from import?
This is the full traceback:
Traceback (most recent call last):
File "manage.py", line 7, in <module>
startup.manage(path=os.path.dirname(os.path.abspath(__file__)))
File "/virtualenv/lib/python2.7/site-packages/aldryn_django/startup.py", line 11, in manage
utility.execute()
File "/virtualenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/virtualenv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/virtualenv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/virtualenv/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/app/forum/models.py", line 9, in <module>
import markdown
ImportError: No module named markdown
A Divio Cloud Django project runs inside a Docker container, and that project must be able to recreate itself anew at any time when required. So, rather than simply installing a package such as Markdown into it, you have to provide the instructions so that it knows to install Markdown next time it has to be rebuilt.
To do this, list it in the project's
requirements.in
file:(Choose the appropriate version of markdown, obviously.)
The reason that
import datetime
works is that datetime is already installed in the project.