因此,作为上下文,我正在用 Python 编写一些控制器软件,用于实验室使用的 RTM3004 示波器。我在我的笔记本电脑 (Win10) 和以前的实验室计算机 (Linux) 上运行得很好,但是在更换到新的测量计算机后,我无法再使用 Pyvisa 连接到设备。这是错误的控制台日志,每当我尝试通过 Pyvisa 连接到设备时就会发生这种情况:
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvisa as visa
>>> rm= visa.ResourceManager()
>>> rm.list_resources()
('ASRL1::INSTR', 'ASRL3::INSTR', 'USB0::2733::470::103028::0::INSTR')
>>> ID='USB0::2733::470::103028::0::INSTR'
>>> instr=rm.open_resource(ID)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 3304, in open_resource
res.open(access_mode, open_timeout)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\resource.py", line 297, in open
self.session, status = self._resource_manager.open_bare_resource(
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 3232, in open_bare_resource
return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\highlevel.py", line 167, in open
sess = cls(session, resource_name, parsed, open_timeout)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\sessions.py", line 323, in __init__
self.after_parsing()
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\usb.py", line 81, in after_parsing
self.interface = self._intf_cls(
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\protocols\usbtmc.py", line 293, in __init__
self.usb_dev.set_configuration()
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\usb\core.py", line 905, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\usb\core.py", line 113, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\usb\core.py", line 159, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\usb\backend\libusb0.py", line 509, in set_configuration
_check(_lib.usb_set_configuration(dev_handle, config_value))
File "C:\Users\Hbeam\AppData\Local\Programs\Python\Python39\lib\site-packages\usb\backend\libusb0.py", line 447, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'
以及我从pyvisa-info
获得的信息:
Machine Details:
Platform ID: Windows-10-10.0.18362-SP0
Processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
Python:
Implementation: CPython
Executable: c:\users\hbeam\appdata\local\programs\python\python39\python.exe
Version: 3.9.4
Compiler: MSC v.1928 64 bit (AMD64)
Bits: 64bit
Build: Apr 6 2021 13:40:21 (#tags/v3.9.4:1f2e308)
Unicode: UCS4
PyVISA Version: 1.11.3
Backends:
ivi:
Version: 1.11.3 (bundled with PyVISA)
Binary library: Not found
py:
Version: 0.5.2
ASRL INSTR: Available via PySerial (3.5)
USB INSTR: Available via PyUSB (1.1.1). Backend: libusb0
USB RAW: Available via PyUSB (1.1.1). Backend: libusb0
TCPIP INSTR: Available
TCPIP SOCKET: Available
GPIB INSTR:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of funcionality.
No module named 'gpib'
我已经为此绞尽脑汁了两个工作日,但看不到解决方案,所以我认为最好寻求帮助,因为我显然不是编程天才。提前致谢。