スクリプトが Babel 関数を呼び出すと、Python Babel パッケージ内からこの例外がスローされます。問題は、コマンドラインから実行すると問題なく動作することです。ただし、これはcronから実行すると発生するエラーです。環境やロケールの設定、または不足に関連している可能性があります。
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 508, in format_datetime
return parse_pattern(format).apply(datetime, locale)
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 702, in apply
return self % DateTimeFormat(datetime, locale)
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 699, in __mod__
return self.format % other
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 724, in __getitem__
return self.format_month(char, num)
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 793, in format_month
return get_month_names(width, context, self.locale)[self.value.month]
File "/home/myproj/lib/python2.6/Babel-0.9.5-py2.6.egg/babel/dates.py", line 87, in get_month_names
return Locale.parse(locale).months[context][width]
AttributeError: 'NoneType' object has no attribute 'months'
アップデート
コマンド ラインから呼び出された場合のロケールは en_US で、cron から呼び出された場合は None です。cronから呼び出すときにどのように設定しますか?
また、これが重要かどうかはわかりませんが、Babel を呼び出すスクリプトはカスタム django-admin コマンドです。