从源代码构建的 Python 找不到 UTF-32-BE 编码



我正在开发一个定制的Linux。当我使用请求做一些HTTP帖子时,出现了导入异常,idna中的东西。再说一句,我的系统是一个小端Linux。

>>> from uts46data import uts46data
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
LookupError: unknown encoding: utf-32-be
>>>

我已经检查了以下编码。

>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>> sys.getfilesystemencoding()
'ANSI_X3.4-1968'

我想这是一个编码问题,那我该怎么办?

更多信息如下。

/ # python -c "import sys;print(sys.version)"
2.7.8 (default, Jul  7 2020, 07:25:41) 
[GCC 7.3.1 20180425]
/ # python -c "import codecs;print codecs.lookup('utf-32-be')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
LookupError: unknown encoding: utf-32-be
/ # 

回答我自己。

Python 将从编码目录中定位它的编码文件。您可以从 Python 源包的 Lib/encodings 目录下复制相应的编码文件。

相关内容

最新更新