Python 冷冻罐';输入JSONDecoder
以下python脚本运行良好:Python 冷冻罐';输入JSONDecoder,python,json,cx-freeze,Python,Json,Cx Freeze,以下python脚本运行良好: #!/usr/bin/python import simplejson print str(simplejson.loads('{"a": "abc"}')) 然后在冻结之后: cxfreeze test.py --target-dir dist Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/cx_Freeze/initscripts/Console.py",
#!/usr/bin/python
import simplejson
print str(simplejson.loads('{"a": "abc"}'))
然后在冻结之后:
cxfreeze test.py --target-dir dist
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/cx_Freeze/initscripts/Console.py", line 29, in <module>
exec code in m.__dict__
File "test.py", line 3, in <module>
import simplejson as json
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 111, in <module>
from decoder import JSONDecoder, JSONDecodeError
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 29, in <module>
NaN, PosInf, NegInf = _floatconstants()
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 21, in _floatconstants
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
LookupError: unknown encoding: hex
从simplejson切换到json也没有帮助
在冻结simplejson部件时,它似乎没有给出任何错误:
P simplejson /usr/lib/python2.7/dist-packages/simplejson/__init__.py
m simplejson._speedups /usr/lib/python2.7/dist-packages/simplejson/_speedups.so
m simplejson.decoder /usr/lib/python2.7/dist-packages/simplejson/decoder.py
m simplejson.encoder /usr/lib/python2.7/dist-packages/simplejson/encoder.py
m simplejson.ordered_dict /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.py
m simplejson.scanner /usr/lib/python2.7/dist-packages/simplejson/scanner.py
(以转载作为答复)
您需要包括模块
编码.hex\u codec
。我已打开以自动完成此操作。添加:
从编码导入十六进制编码解码器
并在使用freeze.py构建时添加-m编码。
它在我这边起作用。您需要包括模块
编码。十六进制编解码器
。我已经打开自动完成这项工作。如果你把它放在“答案”中,我会接受它。它现在运行。它只在ignoredI中给出了这个错误:Exception KeyError:KeyError(140052806182656),我只是试图复制它,但我无法。我不确定你的Python安装和我的有什么不同(我在Ubuntu12.10上尝试了2.6.8和2.7.3)。
P simplejson /usr/lib/python2.7/dist-packages/simplejson/__init__.py
m simplejson._speedups /usr/lib/python2.7/dist-packages/simplejson/_speedups.so
m simplejson.decoder /usr/lib/python2.7/dist-packages/simplejson/decoder.py
m simplejson.encoder /usr/lib/python2.7/dist-packages/simplejson/encoder.py
m simplejson.ordered_dict /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.py
m simplejson.scanner /usr/lib/python2.7/dist-packages/simplejson/scanner.py