将带有VISA库的PyVISA包含到cx_Freeze的EXE中

时间:2014-06-23 08:15:03

标签: python cx-freeze visa

在安装了NI-VISA的开发PC上,一切正常。现在我尝试为其他PC制作一个“All-In-One” - 可执行cx_Freeze。我想出了我在setup.py中包含的以下DLL(同样地,我使用GTK + 3成功完成)。

###################
##### NI-VISA #####
###################

## path to Windows libraries
visa_windows_dir = os.path.join("C:\\", "Windows", "SysWOW64")

## list of missing dlls from Windows directory
missing_visa_windows = [# Listdll.exe(with PyVISA) minus Listdll.exe(without PyVISA)
                    'msvcr71.dll',
                    'nipal32.dll',
                    'nipalu.dll',
                    'NiViSv32.dll',
                    'nipalut.dll',
                    'nirpc.dll',
                    'visa32.dll'
                    #'crypt32.dll',
                    #'msasn1.dll',
                    #'wintrust.dll',
                    #'winusb.dll',
                    #'wsock32.dll'
                ]


## path to visa libraries
visa_program_dir = os.path.join("C:\\", "Program Files (x86)",
                                "IVI Foundation", "VISA", "WinNT")

## list of missing dlls from program directory
missing_visa_program = [# from Listdlls.exe
                        os.path.join("Bin", "NiVi488.dll"),
                        os.path.join("Bin", "NiViAsrl.dll"),
                        os.path.join("Bin", "NiViEnet.dll"),
                        os.path.join("Bin", "NiViEnetAsrl.dll"),
                        os.path.join("Bin", "NiViPxi.dll"),
                        os.path.join("Bin", "NiViRpc.dll"),
                        os.path.join("Bin", "NiViUsb.dll"),
                        os.path.join("NIvisa", "PxiPlugins", "NiViPpiD.dll"),
                        os.path.join("NIvisa", "PxiPlugins", "NiViPpiP.dll"),
                    ]

在运行EXE时,我仍然收到以下错误:OSError: Could not found VISA library. Please install VISA or pass its location as an argument.

我必须包含哪些文件/目录以及如何将其位置传递给pyVISA以便在cx_Freeze环境中运行?

1 个答案:

答案 0 :(得分:1)

这取决于您使用哪个后端。

例如,我将pyvisa软件包与后端pyvisa-py一起使用,之后仅需要在cx_freeze设置文件中包含的文件是“ visa32.dll”,而软件包“ pyvisa_py”