Using SCSS with a Flask

I am trying to use scss with Flask and automatically compile it.

I tried using Flask-Scss - unfortunately, when I installed it, I get Scanning acceleration disabled (_speedups not found)! errors Scanning acceleration disabled (_speedups not found)! and the CSS file is missing. Does anyone know how to fix this, or get it to create CSS files?

+4
source share
1 answer

The error occurs due to an error during the installation process. If you install via 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 need to make sure that you have the libpcre3-dev library installed (this is the module containing pcre.h , the module with which the C-installation fails):

  apt-get install libpcre3-dev 

After that, reset the -scss checkbox:

 pip install Flask-scss --force-reinstall -I 

After restarting the Flask server, the error should be a thing of the past.

But please pay attention

Although the _speedups not found error will be resolved above, there is another probable reason that your files will not be compiled. If you have a 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 installing debug anywhere else, then you have to install

 app.debug = True 

before calling the Scss object:

 app.debug = True Scss(app, static_dir='static', asset_dir='assets') 

Happiness! This should do the trick so that your .scss files are collected every time you load the page in debug mode.

+7
source

Source: https://habr.com/ru/post/1440974/


All Articles