2

我已经在 virtualenv 下的 Django 1.4.1 应用程序上安装了django-pipeline,但是当我运行时python manage.py collectstatic,我得到:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/core/management/__init__.py", line 459, in execute_manager
    utility.execute()
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
    collected = self.collect()
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 119, in collect
    dry_run=self.dry_run)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/storage.py", line 30, in post_process
    packager.pack_stylesheets(package)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/packager.py", line 90, in pack_stylesheets
    variant=package.variant, **kwargs)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/packager.py", line 100, in pack
    content = compress(paths, **kwargs)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/compressors/__init__.py", line 76, in compress_css
    css = getattr(compressor(verbose=self.verbose), 'compress_css')(css)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/compressors/yui.py", line 14, in compress_css
    return self.compress_common(css, 'css', settings.PIPELINE_YUI_CSS_ARGUMENTS)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/compressors/yui.py", line 8, in compress_common
    return self.execute_command(command, content)
  File "/home/hg/VIRTUALENVS/movie/lib/python2.6/site-packages/pipeline/compressors/__init__.py", line 235, in execute_command
    pipe.stdin.write(smart_str(content))
IOError: [Errno 32] Broken pipe

我的设置是:

# static
STATIC_ROOT = join(REPOSITORY_ROOT, 'static_collected')
STATIC_URL = '/static/'
STATICFILES_DIRS = (join(REPOSITORY_ROOT, 'static'),)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

# pipeline (css/js compression)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE = True
PIPELINE_CSS = {
    'base_style': {
        'source_filenames': (
            'css/style.css',
            'css/effects.css',
            'css/rs_style.css',
            'css/jq/jquery-ui-movieplayer.css',
        ),
        'output_filename': 'CACHE/css/style.css',
    },
}

PIPELINE_JS = {
    'base_scripts': {
        'source_filenames': (
          'js/jq/jquery.js',
          'js/mv.core.js',
          'js/toolbox/toolbox.core.js',
          'js/swfobject.js',
          'swf/jwplayer5.9.2156.js',
          'js/jq/jquery-ui.custom.min.js',
          'js/mongo_autocomplete.js',
          'js/rs_script.js',
        ),
        'output_filename': 'CACHE/js/scripts.js',
    }
}

在添加 django-pipeline 之前,管理命令运行良好,它找到了所有内容,因此与查找静态文件或目录权限无关。Yuicompressor 是全局安装的,可以在下面找到,/usr/local/bin/yuicompressor所以我没有PIPELINE_YUI_BINARY在我的设置中修改。

有什么线索吗?谢谢!

4

2 回答 2

2
IOError: [Errno 32] Broken pipe

这个错误意味着yuicompressor在我们有时间发送数据之前已经退出(大部分时间是因为它崩溃或因为它没有被发现)。检查您的yuicompressor路径,并检查是否yuicompressor确实有效。

于 2012-09-06T16:12:23.570 回答
0

在设置中添加可执行文件的路径,例如

PIPELINE_YUI_BINARY = '/usr/bin/yui-compressor'
PIPELINE_LESS_BINARY = '/usr/local/lib/node_modules/less/bin/lessc' 

路径可能不同(尤其是对于 lessc,在此示例中,less 是使用“npm install -g less”安装的)

于 2012-08-29T15:09:51.427 回答