我目前在依赖 Pymeasure 库的代码上使用 PyInstaller 时遇到困难。该程序在提示符下工作正常,但从 PyInstaller 生成的可执行文件启动时却不行。
这是一个在提示下工作但在冻结时不工作的代码的简单示例:
import visa
from pymeasure.instruments.keithley import Keithley2000, Keithley2400
rm = visa.ResourceManager()
list_available = rm.list_resources()
print(list_available)
keithley = Keithley2400("GPIB1::23")
keithley.apply_current() # Sets up to source current
keithley.source_current_range = 10e-3 # Sets the source current range to 10 mA
keithley.compliance_voltage = 10 # Sets the compliance voltage to 10 V
keithley.source_current = 0 # Sets the source current to 0 mA
keithley.enable_source() # Enables the source output
keithley.measure_voltage() # Sets up to measure voltage
keithley.ramp_to_current(5e-3) # Ramps the current to 5 mA
print(keithley.voltage) # Prints the voltage in Volts
keithley.shutdown() # Ramps the current to 0 mA and disables output
请注意,我安装了 PyVISA 1.9.1。
为什么我会收到此错误,我该如何解决?