1

我正在使用这个库在我的 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 和 Linux 上运行良好。

我认为这是路径和斜杠、反斜杠的问题。有任何想法吗?

4

1 回答 1

0

Windows 的 django-less 存在问题。它使用 subprocess 调用lessc命令,但是,正如您在此处看到的,您需要传递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)
于 2013-03-25T14:53:11.207 回答