Search code examples
djangosasslibsass

How do I configure Django to look at the correct Sass installation?


I've taken over a project and I'm having some difficulty getting the server running.

I'm getting the error:

'module' object has no attribute 'compile'

When I go into a shell:

>>> from django_libsass import SassCompiler
>>> import sass
<module 'sass' from '/home/.../venv/local/lib/python2.7/site-packages/sass.so'>
>>> print sass.compile(string='a { b { color: blue; } }')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'compile'

pip freeze reports that the following are installed:

libsass==0.13.5
django-libsass==0.7
sass==2.3

which sass shows /usr/bin/sass which is version 3.4.21.

I take it it might be an issue with my settings. Nothing explicitly sets any paths but I do have this:

STATIC_PRECOMPILER_COMPILERS = (
    ('static_precompiler.compilers.libsass.SCSS', {
        "sourcemap_enabled": True,
        "load_paths": ["/path"],
        "precision": 8,
    }),
    ('static_precompiler.compilers.libsass.SASS', {
        "sourcemap_enabled": True,
        "load_paths": ["/path"],
        "precision": 8,
    }),
)

Solution

  • The problem was this:

    sass==2.3
    

    libsass and django-libsass provide a sass module for you, and installing any other sass module with pip only serves to obscure libsass.