2013-01-10 2 views
0

를 가져올 수 없습니다 :나 cx_Freeze 다음 파이썬 스크립트는 잘 실행 JSONDecoder를

#!/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으로 전환했습니다.

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 
+1

'encodings.hex_codec' 모듈을 포함해야합니다. 이 문제를 자동으로 해결하기 위해 [문제] (https://bitbucket.org/anthony_tuininga/cx_freeze/issue/17/hooks-python-2-json-simplejson-dynamically)를 열었습니다. –

+0

"대답"에 넣으면 받아 들일 것입니다. 이제 실행됩니다. 예외 : 예외 KeyError : 'module'threading 'from'/dist/test/threading.pyc '>의 KeyError (140052806182656)가 무시되었습니다. –

+0

방금 ​​복제하려고 시도했지만 할 수 없었습니다. 나는 파이썬 설치와 다른 점이 무엇인지 모르겠습니다. (우분투에서 2.6.8과 2.7.3으로 시도했습니다.) –

답변

1

(답변으로 재개시) 당신은 모듈 encodings.hex_codec을 포함 할 필요가

:

는 simplejson 부분을 동결 오류를주지 보인다. 이 작업을 자동으로 수행하려면 an issue을 열었습니다.

0

추가 : 인코딩에서

이 hex_codec

가져 구축 freeze.py를 사용하는 경우 -m 인코딩를 추가합니다. 내 측면에서 작동합니다.