0

次の 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", 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

これは役に立ちません:

cxfreeze test.py --target-dir dist --include-modules simplejson

また、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
4

2 に答える 2

1

(回答として再投稿)

モジュールを含める必要がありますencodings.hex_codec。これを自動的に行うためにイシューをオープンしました。

于 2013-01-11T17:26:36.340 に答える
0

追加:

エンコーディングから import hex_codec

また、 freeze.py を使用してビルドするときに-m エンコーディングを追加します。それは私の側で動作します。

于 2015-07-07T06:02:35.207 に答える