1

I am using this library to run lesscss on my django project : https://github.com/andreyfedoseev/django-less/

It works fine on Mac and Linux but I am getting an error on Windows and can't find a solution.

Here's the django error :

Request Method: GET
Request URL:    localhost:8000
Django Version: 1.4.5
Exception Type: WindowsError
Exception Value:    2 The system cannot find the specified file
Exception Location: C:\Python27\lib\subprocess.py in _execute_child, line 896
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.3
Python Path:    
['C:\\soundgathr\\GemsBand',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']
Server time:    Fri, 22 Mar 2013 23:42:11 +0100
Error during template rendering

In template C:\soundgathr\GemsBand\static\templates\blocks\head.html, error at line 7

Here is my call to less in my template :

<link rel="stylesheet" href="{% less "less/common.less" %}" />

and my settings.py :

# Less path settings
LESS_OUTPUT_URL = os.path.join(MEDIA_URL, 'LESS_CACHE')
LESS_OUTPUT_DIR = os.path.join(MEDIA_ROOT, 'LESS_CACHE')

Again, it works fine on Mac & Linux.

I think it's an issue of paths and slash, backslash. Any ideas?

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
  • [This](http://stackoverflow.com/a/2359378/1048479) SO post may contain some helpful info. Particularly the suggestion of using ``posixpath.join()`` instead of ``os.path.join()`` to keep things consistent across different oses. – Nick Tomlin Mar 22 '13 at 14:57
  • @NickTomlin Thanks for your reply. Sadly, using `posixpath.join()` does not seem to change anything in my case. – Clément Grellier Mar 22 '13 at 16:47
  • The lines above your error will tell you (us) in which piece of code the error occurs - care to share that with us too? – danodonovan Mar 22 '13 at 20:50
  • My "idea" would be to just use Grunt and precompile the stylesheets before deploying... Seems like a more natural fit than having your webapp call the binary compiler on demand. – millimoose Mar 22 '13 at 22:46
  • Is `lessc` in your `%PATH%`? Open a commandline and try running it (or whatever your `LESS_EXECUTABLE` is set to) – ebsddd Mar 23 '13 at 01:58
  • @millimoose Hm maybe it would work, but I would really like to get it to work with this configuration. @valtron yes, i can run `lessc`, I am pretty sure I installed it properly. Thanks for your help. – Clément Grellier Mar 23 '13 at 13:51

1 Answers1

0

There is an issue in django-less for Windows. It uses subprocess to call the lessc command, but, as you can see here, you need to pass shell=True to make it work on Windows.

Try to change the following line in django-less/utils.py

p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

by

p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Community
  • 1
  • 1