我有一个python2.7脚本sendpord.py它使用SUDS与web服务通信。在脚本中,我调用了一个web服务方法,将一些参数作为字符串传递(runJob(par1, par2, par3)
)。它能很好地与西欧字符在弦乐。我用PyDev在Eclipse中运行它。
然后我使用py2exe生成.exe。现在它给了我错误
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)
导致错误的代码是:
^{pr2}$经过调查,我发现删除°èòà
之类的字符可以解决问题。。。但我不能!我必须保留我正在传递的弦。
所以我在传递字符串之前尝试了解码:
result = ws_client.service.runJob(par1.decode('latin9'), par2.decode('latin9'), par3.decode('latin9'))
同样,所有操作都在.py中工作,但在.exe中不工作。也许PyDev用某种方式纠正了这个问题?
附件
在设置.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
Python对编码转换的猜测让您吃了一惊。您尝试的第一部分是正确的:首先用(希望是正确的)编码解码。在你发出去之前,你必须 再次对其进行编码,最好使用UTF-8之类的代码,否则Python将尝试“默认”编码(在大多数安装中是ASCII)。I've written this here before
相关问题 更多 >
编程相关推荐