带有cx_Freeze TypeError的pyVisa错误:意外的关键字argumen

2024-05-16 05:30:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个使用pyvisa的脚本。在python控制台上一切正常,但冻结时我得到了一个TypeError。在

在调试.py公司名称:

import visa

def main():
    visa.log_to_screen()
    rm = visa.ResourceManager()
    # works
    instr = rm.open_resource("GPIB0::12::INSTR")
    # fails in frozen executable
    instr = rm.open_resource("GPIB0::12::INSTR", write_termination="\r\n")
if __name__=="__main__":
    main()

在设置.py公司名称:

^{pr2}$

执行冻结脚本:

O:\>build\exe.win32-3.3\debug.exe
2015-02-06 09:51:38,270 - pyvisa - DEBUG - Created library wrapper for C:\Windows\system32\visa32.dll
2015-02-06 09:51:38,290 - pyvisa - DEBUG - viOpenDefaultRM(<cparam 'P' (02BCDA58)>,) -> 0
2015-02-06 09:51:38,290 - pyvisa - DEBUG - Created ResourceManager with session8240592
2015-02-06 09:51:38,360 - pyvisa - DEBUG - viOpen(8240592, 'GPIB0::12::INSTR', 0, 0, <cparam 'P' (02BCDA58)>) -> 1073676413
O:\build\exe.win32-3.3\library.zip\pyvisa\ctwrapper\functions.py:1059: VisaIOWarning: VI_SUCCESS_DEV_NPRESENT (1073676413): Session opened successfully, but the device at the specified address is not responding.
Traceback (most recent call last):
  File "C:\Python\WinPython-32bit-3.3.2.3\python-3.3.2\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module>
  File "debug.py", line 14, in <module>
    main()
  File "debug.py", line 12, in main
    instr = rm.open_resource("GPIB0::12::INSTR", write_termination="\r\n")
TypeError: open_resource() got an unexpected keyword argument 'write_termination'

这种重新定义从何而来?在


Tags: rminpydebugmainvisaopenexe