Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.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
Django-使用Apache的生产环境中的UnicodeError_Django_Apache - Fatal编程技术网

Django-使用Apache的生产环境中的UnicodeError

Django-使用Apache的生产环境中的UnicodeError,django,apache,Django,Apache,我在生产中遇到一个Django应用程序,它抛出以下错误: 'ascii' codec can't encode character u'\xe9' in position 97: ordinal not in range(128) Unicode error hint The string that could not be encoded/decoded was: P Gen@rica. pGen@rica是上载文件名称的一部分 出现错误的代码如下: files_list = [uuid_t

我在生产中遇到一个Django应用程序,它抛出以下错误:

'ascii' codec can't encode character u'\xe9' in position 97: ordinal not in range(128)
Unicode error hint
The string that could not be encoded/decoded was: P Gen@rica.
pGen@rica是上载文件名称的一部分

出现错误的代码如下:

files_list = [uuid_temp_files + '/' + f for f in os.listdir(uuid_temp_files) if os.path.isfile(os.path.join(uuid_temp_files, f))]
在我的开发机器中,一切正常,我可以在文件名中添加重音文件名

关于生产环境中此错误的原因有什么线索吗?可能是一些Apache配置


致以最诚挚的问候,

问题已通过以下方式得到纠正:

# CentOS use /etc/sysconfig/httpd to config environment variables.
#
# By default, the httpd process is started in the C locale; to
# change the locale in which the server runs, the LANG
# variable can be set.
#
# LANG=C
LANG=en_US.UTF-8  # you can change to your locale.
在文件“/etc/sysconfig/httpd”中将“LANG=C”更改为“LANG=en_US.UTF-8”,然后重新启动Apache


完成。

我假设您是开发人员,机器使用的是python 3?它使用的是python 2.7为什么不在列表左侧使用
os.path.join