2014-11-05 153 views
0

我在django和python中使用newbe。我的项目是在PyTools for Visual Studio 2013下创建的。 对于本地化,我在manage.py级别创建'locale'文件夹。我尝试运行下面的命令:命令'makemessages'错误

\ ClarisPyEnv \脚本\ python.exe manage.py makemessages -l他

,我得到了错误:

Exception in thread Thread-2377: 
Traceback (most recent call last): 
    File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner 
    self.run() 
    File "C:\Python34\lib\threading.py", line 869, in run 
    self._target(*self._args, **self._kwargs) 
    File "C:\Python34\lib\subprocess.py", line 1170, in _readerthread 
    buffer.append(fh.read()) 
    File "C:\Python34\lib\encodings\cp1255.py", line 23, in decode 
    return codecs.charmap_decode(input,self.errors,decoding_table)[0] 
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 766: char 
acter maps to <undefined> 

Traceback (most recent call last): 
    File "manage.py", line 17, in <module> 
    execute_from_command_line(sys.argv) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\__init__.py", line 385, in execute_from_co 
mmand_line 
    utility.execute() 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\__init__.py", line 377, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\base.py", line 288, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\base.py", line 338, in execute 
    output = self.handle(*args, **options) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\base.py", line 533, in handle 
    return self.handle_noargs(**options) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\commands\makemessages.py", line 290, in ha 
ndle_noargs 
    self.write_po_file(potfile, locale) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\commands\makemessages.py", line 402, in wr 
ite_po_file 
    msgs, errors, status = popen_wrapper(args) 
    File "C:\Users\Alex\Documents\PythonProjects\ClarisPy\ClarisPy\ClarisPyEnv\lib 
\site-packages\django\core\management\utils.py", line 25, in popen_wrapper 
    output, errors = p.communicate() 
    File "C:\Python34\lib\subprocess.py", line 959, in communicate 
    stdout, stderr = self._communicate(input, endtime, timeout) 
    File "C:\Python34\lib\subprocess.py", line 1234, in _communicate 
    stdout = stdout[0] 
IndexError: list index out of range 

这意味着什么?哪里有问题?请帮帮我!

感谢 亚历

+0

我认为这是一个解码问题,你是否像这样编写测试? _(ü“你在这里输入文本”),'_'是'ugettext as _',u是Unicode文本。 – 2014-11-05 08:59:06

+0

在我views.py文件中写道 context_instance = RequestContext的(请求, { '标题':_(u'Home页“), '年':datetime.now()年, }) 哪里我可以写测试吗?请解释。 – 2014-11-05 09:45:14

+0

而我不明白 - 错误在哪里?在哪个文件中? – 2014-11-05 09:48:53

回答

0

你不需要在pyhton 3 统一指定unicode是默认的。

from django.utils.translation import ugettext as _

_('חתול')

是针对翻译和编码工作enof。

+0

好的。我明白。但为什么我得到了错误? – 2014-11-05 10:27:05

+0

从我能看到的: 'File“C:\ Python34 \ lib \ subprocess.py”,1234行,在_communicate stdout = stdout [0]' 正试图打印出终端?并且大多数终端不支持unicode编码。默认设置为 – Persijn 2014-11-05 12:45:04

+0

为什么终端?我尝试为我的项目生成django.po文件。我启动命令。\ ClarisPyEnv \ Scripts \ python.exe manage.py makemessages -l他从终端窗口。我必须在。\ locale \ he \ LC_MESSAGES目录中获取文件django.po。但我得到了错误。 – 2014-11-05 12:53:21