@@ -11,19 +11,17 @@
 
 from __future__ import unicode_literals
 from optparse import OptionParser
-from jinja2 import Environment, FileSystemLoader
+from jinja2 import Environment, PackageLoader
 from slugify import slugify_unicode
 import json
-import os
 
 
-LIB_DIR = os.path.dirname(globals()['__file__'])
-
 CONTENT_FILENAME = "./content.html"
 PAGE_FILENAME = "./page.html"
 
-jinja2_env = Environment(lstrip_blocks=True, trim_blocks=True)
-jinja2_env.loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates'))
+
+pl = PackageLoader('nvd3', 'templates')
+jinja2_env = Environment(lstrip_blocks=True, trim_blocks=True, loader=pl)
 
 template_content = jinja2_env.get_template(CONTENT_FILENAME)
 template_page = jinja2_env.get_template(PAGE_FILENAME)
@@ -45,11 +43,11 @@ class NVD3Chart(object):
     #:  directory holding the assets (bower_components)
     assets_directory = './bower_components/'
 
-    CHART_FILENAME = None  # this attribute is overriden by children of this
-                           # class
-    template_environment = Environment(lstrip_blocks=True, trim_blocks=True)
-    template_environment.loader = FileSystemLoader(os.path.join(
-        os.path.dirname(__file__), 'templates'))
+    # this attribute is overriden by children of this
+    # class
+    CHART_FILENAME = None
+    template_environment = Environment(lstrip_blocks=True, trim_blocks=True,
+                                       loader=pl)
 
     def __init__(self, **kwargs):
         """