CentOS 7 / Apache / mod_wsgi - UnicodeDecodeError:'ascii' 编解码器无法解码位置 2727 中的字节 0xc2:序数不在范围内(128)

CentOS 7 / Apache / mod_wsgi - UnicodeDecodeError:'ascii' 编解码器无法解码位置 2727 中的字节 0xc2:序数不在范围内(128)

我已经使用 mod_wsgi 在 Apache(httpd)中部署了一个 Python Web 应用程序(使用 Pyramid)。

启动 Apache 服务后,当我们向 Web 应用程序发出 http 请求时,会发生以下错误(来自 Apache 日志)...

[Mon Feb 06 16:38:55.980119 2017] [wsgi:error] [pid 16031] [remote 172.16.13.1:204] mod_wsgi (pid=16031): Target WSGI script '/usr/local/lb/ve32/src/LBGenerator/lbgenerator.wsgi' cannot be loaded as Python module.
[Mon Feb 06 16:38:55.980205 2017] [wsgi:error] [pid 16031] [remote 172.16.13.1:204] mod_wsgi (pid=16031): Exception occurred processing WSGI script '/usr/local/lb/ve32/src/LBGenerator/lbgenerator.wsgi'.
Traceback (most recent call last):
  File "/usr/local/lb/ve32/src/LBGenerator/lbgenerator.wsgi", line 1, in <module>
    from pyramid.paster import get_app
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/paster.py", line 10, in <module>
    from pyramid.scripting import prepare
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/scripting.py", line 1, in <module>
    from pyramid.config import global_registries
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/config/__init__.py", line 30, in <module>
    from pyramid.exceptions import (
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/exceptions.py", line 1, in <module>
    from pyramid.httpexceptions import (
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/httpexceptions.py", line 138, in <module>
    from pyramid.response import Response
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/response.py", line 23, in <module>
    init_mimetypes(mimetypes)
  File "/usr/local/lb/ve32/lib/python3.2/site-packages/pyramid-1.5.1-py3.2.egg/pyramid/response.py", line 16, in init_mimetypes
    mimetypes.init()
  File "/usr/local/lb/py32/lib/python3.2/mimetypes.py", line 351, in init
    db.read(file)
  File "/usr/local/lb/py32/lib/python3.2/mimetypes.py", line 203, in read
    self.readfp(fp, strict)
  File "/usr/local/lb/py32/lib/python3.2/mimetypes.py", line 214, in readfp
    line = fp.readline()
  File "/usr/local/lb/py32/lib/python3.2/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2727: ordinal not in range(128)

该 Web Python 应用程序在所有这些发行版中均可完美运行:Ubuntu 14.04、Debian 8、RedHat 6、CentOS 6、Suse 12 和 openSUSE 13,但在 CentOS 7 中则不行... =[

我们在“CentOS 7”中使用“Python 3.2.2”、“mod_wsgi 4.3.2”和“Apache 2.4.6”。Web应用程序建立在 Pyramid Web Framework 之上(http://docs.pylonsproject.org/projects/pyramid/en/latest/)。

这是一个相当常见的错误!到目前为止,我还没有找到获取有关此错误的更多信息的方法。

我们已经尝试了所有方法来解决这个问题,但我们就是不知道为什么会发生这种情况... =[

请帮我!

答案1

出现此问题的原因是CentOS 7 的文件包含对 ascii 无效的 /etc/mime.types字符"³"(line )(未扩展)。 为了解决这个问题,我不得不对我的 Python 3.2.2 进行一些修改并重新加载我的应用程序。 解决方案是删除该字符或任何其他无效(ascii)字符! @MichaelHampton "application/vnd.geocube+xml g3 g³"



"³"


谢谢!

相关内容