Python pyVisa with cx_Freeze-TypeError:意外的关键字参数
我有一个使用pyvisa的脚本。在python控制台上,一切正常,但我遇到了一个类型错误 debug.py:Python pyVisa with cx_Freeze-TypeError:意外的关键字参数,python,python-3.x,cx-freeze,visa,Python,Python 3.x,Cx Freeze,Visa,我有一个使用pyvisa的脚本。在python控制台上,一切正常,但我遇到了一个类型错误 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
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'
O:\>build\exe.win32-3.3\debug.exe
2015-02-06 09:51:38270-pyvisa-DEBUG-为C:\Windows\system32\visa32.dll创建库包装
2015-02-06 09:51:38290-pyvisa-DEBUG-viOpenDefaultRM(,)->0
2015-02-06 09:51:38290-pyvisa-DEBUG-Created-ResourceManager与session8240592
2015-02-06 09:51:38360-pyvisa-DEBUG-viOpen(8240592,'GPIB0::12::INSTR',0,0,)->1073676413
O:\build\exe.win32-3.3\library.zip\pyvisa\ctwrapper\functions.py:1059:VisaIOWarning:VI_SUCCESS\u DEV_present(1073676413):会话成功打开,但指定地址的设备没有响应。
回溯(最近一次呼叫最后一次):
文件“C:\Python\WinPython-32bit-3.3.2.3\Python-3.3.2\lib\site packages\cx\u Freeze\initscripts\Console3.py”,第27行,在
文件“debug.py”,第14行,在
main()
文件“debug.py”,第12行,在main中
instr=rm.open\u资源(“GPIB0::12::instr”,write\u termination=“\r\n”)
TypeError:open\u resource()获得意外的关键字参数“write\u termination”
这种重新定义从何而来?开源方法中真的存在一个
写终止
参数吗?是的。打开instr
后,它被转发到。