2014-11-05 155 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