I'm trying to use scss with Flask and get it to auto-compile.
I've tried using Flask-Scss — unfortunately, when I set it up, I get Scanning acceleration disabled (_speedups not found)!
errors, and no CSS file. Anyone know how to fix this, or get it to generate CSS files?
The error results from an error in the installation process. If you install through pip
on an Ubuntu system and you get this warning:
==========================================================================
WARNING: The C extension could not be compiled, speedups are not enabled.
Plain-Python installation succeeded.
==========================================================================
Then you should make sure you have the libpcre3-dev
library pre-installed (this is the module that contains pcre.h
, the module that the C-installation fails on):
apt-get install libpcre3-dev
After doing this, re-install Flask-Scss:
pip install Flask-scss --force-reinstall -I
After restarting the Flask server, the error should now be a thing of the past.
Even though the above will solve the problem of the _speedups not found
error showing up, there is another likely reason for your files not getting compiled. If you have code like this:
app = Flask(__name__)
from flask.ext.scss import Scss
Scss(app, static_dir='static', asset_dir='assets')
...
if __name__ == "__main__":
app.run(debug=True)
, and you are not setting debug
anywhere else, then you should make sure to put
app.debug = True
before the invocation of the Scss object:
app.debug = True
Scss(app, static_dir='static', asset_dir='assets')
Happiness! That should do the trick for getting your .scss files to compile every time you load a page in debug mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With