Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UnicodeDecodeError与compilemessages django转换器_Django - Fatal编程技术网

UnicodeDecodeError与compilemessages django转换器

UnicodeDecodeError与compilemessages django转换器,django,Django,我得到这个错误 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128) 而我想用 python django.admin.py manage.py compilemessages 这是我的django.po文件: # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT

我得到这个错误

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
而我想用

python django.admin.py manage.py compilemessages
这是我的django.po文件:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-28 11:39+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: blog/forms.py:6
msgid "name"
msgstr ""

#: blog/forms.py:7
msgid "e-mail"
msgstr ""

#: blog/forms.py:8
msgid "comment"
msgstr ""

#: blog/Template/post.html:34
msgid "send"
msgstr ""
#一些描述性的标题。
#版权(C)软件包版权所有者的年份
#此文件在与包相同的许可证下分发。
#第一作者,年。
#
#,模糊
msgid“”
msgstr“”
“项目Id版本:包版本\n”
“将Msgid错误报告给:\n”
“罐创建日期:2014-05-28 11:39+0000\n”
“采购订单修订日期:年月日:MI+区域\n”
“最后一个转换器:全名\n”
“语言团队:语言\n”
“语言:\n”
“MIME版本:1.0\n”
“内容类型:文本/普通;字符集=UTF-8\n”
“内容传输编码:8位\n”
#:blog/forms.py:6
msgid“名称”
msgstr“”
#:blog/forms.py:7
msgid“电子邮件”
msgstr“”
#:blog/forms.py:8
msgid“评论”
msgstr“”
#:blog/Template/post.html:34
msgid“发送”
msgstr“”
回溯:

 python2.7 manage.py compilemessages
processing file django.po in /home/arash/Lab/django/arash_blog/conf/locale/fa_IR/LC_MESSAGES
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/compilemessages.py", line 71, in handle
    compile_messages(self.stdout, locale=locale)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/compilemessages.py", line 42, in compile_messages
    if not f.endswith('.po'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
python2.7 manage.py编译消息
正在处理/home/arash/Lab/django/arash_blog/conf/locale/fa_IR/LC_消息中的文件django.po
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/usr/lib/python2.7/site packages/django/core/management/_init__.py”,第399行,从命令行执行
utility.execute()
文件“/usr/lib/python2.7/site packages/django/core/management/__init__.py”,第392行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/usr/lib/python2.7/site-packages/django/core/management/base.py”,第242行,运行于_-argv
self.execute(*args,**选项._dict__;
文件“/usr/lib/python2.7/site packages/django/core/management/base.py”,执行中第285行
输出=self.handle(*args,**选项)
文件“/usr/lib/python2.7/site packages/django/core/management/commands/compilemessages.py”,第71行,在handle中
编译消息(self.stdout,locale=locale)
文件“/usr/lib/python2.7/site packages/django/core/management/commands/compilemessages.py”,第42行,在compile_消息中
如果不是f.endswith(“.po”):
UnicodeDecodeError:“ascii”编解码器无法解码位置5中的字节0xc3:序号不在范围内(128)

查看您的回溯,显然,您的
.po
文件没有故障:

File "/usr/lib/python2.7/site-packages/django/core/management/commands/compilemessages.py", line 42, in compile_messages
    if not f.endswith('.po'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
如果没有,请查看

在您的repo中(至少)有一个文件,很可能是Python文件,其中包含非ASCII字符。您只需找到它并将其添加到顶部:

#coding:utf-8
或者该文件使用的任何编码。因为您使用的是Linux,所以最有可能是
utf-8
,但这可能取决于您的编辑器


如果您在查找上述文件时遇到困难,只需打开
/usr/lib/python2.7/site packages/django/core/management/commands/compilemessages.py
,在第42行
If
子句之前添加一行
print f

然后运行命令。你应该在追踪的上方看到罪犯


找到它后,只需删除print语句。

您使用的是什么版本的python?这不可能是meesage的全部:回溯的其余部分是什么?我使用python 2.7版和