Skip to content

Instantly share code, notes, and snippets.

@cmheisel
Created October 6, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmheisel/982bcc8d31cb472de043 to your computer and use it in GitHub Desktop.
Save cmheisel/982bcc8d31cb472de043 to your computer and use it in GitHub Desktop.
import sys
import pprint
# This formats the path into a nicely readable string
readable_path = pprint.pformat(sys.path)
# We'll try importing and catch the exception if it doesn't work
try:
import django
except ImportError, e:
print "Can't import django from PATH: {}".format(readable_path)
raise # Re-raise the exception so execution stops
# Access the modules __file__ attribute to see where it is
print "Django's location: {}".format(django.__file__)
try:
from django.core.management import execute_from_command_line
print "execute_from_command_line imported successfully!"
except ImportError, e:
print "Can't load execute_from_command_line from {}".format(django.core.management.__file__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment