我正在使用这个库在我的django项目上运行lesscss: https://github.com/andreyfedoseev/django-less/
它在Mac和Linux上运行正常,但我在Windows上收到错误,无法找到解决方案。
这是django错误:
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
以下是我在模板中对less的调用:
<link rel="stylesheet" href="{% less "less/common.less" %}" />
和我的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')
同样,它在Mac&amp; Linux操作系统。
我认为这是路径和斜线,反斜杠的问题。有什么想法吗?
答案 0 :(得分:0)
对于Windows,django-less存在问题。它使用子进程来调用 lessc 命令,但是,as you can see here,您需要传递 shell = True 以使其在Windows上运行。
尝试在django-less / utils.py
中更改以下行p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
通过
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)