OSError在/ [Errno 2]没有这样的文件或目录django资产

时间:2014-02-28 06:38:24

标签: django

我正在尝试运行build static

命令
./manage.py assets build --settings=marketplace.settings.dev

我得到追溯:

Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/web/market/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/web/market/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/web/market/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/web/market/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/home/web/market/local/lib/python2.7/site-packages/django_assets/management/commands/assets.py", line 88, in handle
impl.run_with_argv(args)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/script.py", line 547, in run_with_argv
return self.run_with_ns(ns)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/script.py", line 537, in run_with_ns
return cmd.invoke(ns.command, args)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/script.py", line 371, in invoke
return function(**args)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/script.py", line 171, in __call__
disable_cache=no_cache)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/bundle.py", line 563, in build
disable_cache=disable_cache))
File "/home/web/market/local/lib/python2.7/site-packages/webassets/bundle.py", line 498, in _build
force, disable_cache=disable_cache, extra_filters=extra_filters)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/bundle.py", line 384, in _merge_and_apply
filters_to_pass_down, disable_cache=disable_cache)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/bundle.py", line 453, in _merge_and_apply
return filtertool.apply(final, selected_filters, 'output')
File "/home/web/market/local/lib/python2.7/site-packages/webassets/merge.py", line 269, in apply
return self._wrap_cache(key, func)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/merge.py", line 216, in _wrap_cache
content = func().getvalue()
File "/home/web/market/local/lib/python2.7/site-packages/webassets/merge.py", line 249, in func
getattr(filter, type)(data, out, **kwargs_final)
File "/home/web/market/local/lib/python2.7/site-packages/webassets/filter/coffeescript.py", line 45, in output
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

我可以就如何解决这个问题得到一些相关建议吗?

4 个答案:

答案 0 :(得分:1)

错误发生在您的第三方应用django-assets上,该应用使用了另一个第三方python应用webassets,旨在压缩和最小化Javascript,CSS等网络资源。

问题出在 webassets 上,它隐藏了配置错误的异常,实际原因是找不到执行压缩所需的二进制文件此处您有错误原因https://github.com/miracle2k/webassets/issues/400

确保正确安装所需的操作系统依赖项(二进制文件),以允许django-assets + webassets执行所需的操作。当我第一次尝试其他应用程序(如django-pipeline)时出现类似问题,如果 yuglify 或其他未正确安装的压缩后端存在问题。

答案 1 :(得分:0)

如您所见,他无法找到您的市场设置。 OSError: [Errno 2] No such file or directory

您的marketplace.settings.dev位于此处:

  • /home/web/market/local/lib/python2.7/site-packages/
  • /usr/lib/python2.7/

尝试移动marketplace目录,然后重试。

答案 2 :(得分:0)

查看您的manage.py文件,确保此行指向正确的设置文件

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "marketplace.settings.dev")

答案 3 :(得分:0)

File "/home/web/market/local/lib/python2.7/site-packages/django_assets/management/commands/assets.py", line 88, in handle

以及更多行表示您的命令实际运行。

所以我认为marketplace.settings.dev

没有错
File "/home/web/market/local/lib/python2.7/site-packages/webassets/filter/coffeescript.py", line 45, in output
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

表示您的asset命令正在激活子进程,并且子进程尝试访问的其中一个文件不存在。

我猜你传递给asset命令中的子进程的目录有问题。 (路径设置不正确)

如果您显示asset命令代码,我可能会进一步为您提供帮助。