我有一个使用pyvisa的脚本。在python控制台上一切正常但冻结我得到一个TypeError。
debug.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()
setup.py:
from cx_Freeze import setup, Executable
import os, site
[python_dir, site_dir] = site.getsitepackages()
include_files = []
missing_dll = ["msvcr100.dll"]
for dll in missing_dll:
include_files.append((os.path.join(python_dir, dll), dll))
buildOptions_exe = dict(
compressed = False,
# includes = ["pyvisa"], # doesn't solve this issue
include_files = include_files
)
setup(
name = "Debugger",
author = "Name",
version = "0.0.0",
options = dict(build_exe = buildOptions_exe),
executables = [Executable("debug.py"),]
冻结脚本的执行:
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'
这种重新定义在哪里来自?