2011-09-08 4 views
2

에 의해 생성 된 .exe로 나는 SUDS를 사용하여 웹 서비스와 통신하는 파이썬 2.7 스크립트 SendPreord.py 있습니다. 스크립트에서 일부 매개 변수를 문자열로 (runJob(par1, par2, par3))으로 전달하는 웹 서비스 메서드를 호출합니다. 현악기의 서구 유럽인과 잘 어울립니다. 나는 이클립스에서 PyDev으로 실행한다.UnicodeDecodeError SUDS에서 만 py2exe에

그런 다음 .exepy2exe을 사용하여 생성합니다. 지금은 오류가 원인이 나에게 오류

Traceback (most recent call last): 
    File "SendPreord.py", line 80, in <module> 
    File "suds\client.pyc", line 542, in __call__ 
    File "suds\client.pyc", line 602, in invoke 
    File "suds\client.pyc", line 637, in send 
    File "suds\transport\https.pyc", line 64, in send 
    File "suds\transport\http.pyc", line 77, in send 
    File "suds\transport\http.pyc", line 118, in u2open 
    File "urllib2.pyc", line 391, in open 
    File "urllib2.pyc", line 409, in _open 
    File "urllib2.pyc", line 369, in _call_chain 
    File "urllib2.pyc", line 1173, in http_open 
    File "urllib2.pyc", line 1142, in do_open 
    File "httplib.pyc", line 946, in request 
    File "httplib.pyc", line 987, in _send_request 
    File "httplib.pyc", line 940, in endheaders 
    File "httplib.pyc", line 801, in _send_output 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 484: ordinal not in range(128) 

코드를 제공합니다

result = ws_client.service.runJob(par1, par2, par3) 

가 조사, 나는 °èòà 같은 문자를 제거하여 문제를 해결 것을 깨달았다 ...하지만 그럴 수 없어! 나는 지나가는 끈을 보존해야합니다. 하지만 .EXE에서, 평에서

result = ws_client.service.runJob(par1.decode('latin9'), par2.decode('latin9'), par3.decode('latin9')) 

다시 모든 작품 :

그래서 나는 그들을 전달하기 전에 문자열을 디코딩 시도했다. 어쩌면 PyDev가 문제를 어떤 식 으로든 해결할 것입니까?


부착 장치

Setup.py :

from distutils.core import setup 
import py2exe 
setup(console=['src/SendPreord.py']) 
py2exe에 출력 로그에서

재미있는 추출물 : 당신은 인코딩 변환에 추측 파이썬의 물린 봤는데

*** copy dlls *** 
copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\xxxxxxx\workspace\eclipse\SendPreord\dist\SendPreord.exe 
The following modules appear to be missing 
['ElementC14N', '_scproxy', 'ntlm'] 

*** binary dependencies *** 
Your executable(s) also depend on these dlls which are not included, 
you may or may not need to distribute them. 

Make sure you have the license if you distribute any of them, and 
make sure you don't distribute files belonging to the operating system. 

    USER32.dll - C:\Windows\system32\USER32.dll 
    SHELL32.dll - C:\Windows\system32\SHELL32.dll 
    WSOCK32.dll - C:\Windows\system32\WSOCK32.dll 
    ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll 
    WS2_32.dll - C:\Windows\system32\WS2_32.dll 
    KERNEL32.dll - C:\Windows\system32\KERNEL32.dll 

답변

0

. 시도한 첫 번째 부분은 옳다. 먼저 올바른 인코딩으로 디코딩한다. 보내려면 먼저 을 다시 인코딩해야하며, UTF-8과 같은 것을 사용하는 것이 좋습니다. 그렇지 않으면 파이썬은 "ASCII"(대부분의 설치 프로그램에서) 인코딩을 시도합니다. I've written this here before