6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【備忘録】pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.が出たとき

Last updated at Posted at 2019-08-02

環境

  • Windows 10
  • Python 3.7.3
  • PyVISA 1.9.1

現象

>>> import visa
>>> rm = visa.ResourceManager()
>>> rm.list_resources()

とかやってると、

pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.

というエラーが出てくる。

対処法

$ pyvisa-info
で状態を確認。

$ pyvisa-info
Machine Details:
   Platform ID:    ~略~
   Processor:      Intel64 Family 6 Model 142 Stepping 9, GenuineIntel

Python:
   Implementation: CPython
   Executable:     ~略~
   Version:        3.7.3
   Compiler:       MSC v.1915 64 bit (AMD64)
   Bits:           64bit
   Build:          Apr 24 2019 15:29:51 (#default)
   Unicode:        UCS4

PyVISA Version: 1.9.1

Backends:
   ni:
      Version: 1.9.1 (bundled with PyVISA)
      #1: C:\WINDOWS\system32\visa32.dll:
         found by: auto
         bitness: 64
         Could not get more info:
            VI_ERROR_NSUP_ATTR (-1073807331): The specified attribute is not defined or supported by the referenced object.
      #2: C:\WINDOWS\system32\visa64.dll:
         found by: auto
         bitness: 64
         Could not get more info:
            VI_ERROR_NSUP_ATTR (-1073807331): The specified attribute is not defined or supported by the referenced object.
   py:
      Version: 0.3.1
      ASRL INSTR: Available via PySerial (3.4)
      USB INSTR: Available via PyUSB (1.0.2). Backend: N/A
      USB RAW: Available via PyUSB (1.0.2). Backend: N/A
      TCPIP INSTR: Available
      TCPIP SOCKET: Available
      GPIB INSTR:
         Please install linux-gpib to use this resource type.
         No module named 'gpib'

Backendsのniに注目します。
「C:\WINDOWS\system32\」ディレクトリにあるvisa32.dllとvisa64.dllというファイルを参照していますが、「VI_ERROR_NSUP_ATTR (-1073807331): The specified attribute is not defined or supported by the referenced object.」というエラーが出ています。属性がサポートされていない的なことを言っているようです。

解決するためにここからNI-VISAをダウンロードします。

改めて、pyvisa-infoを打って確認すると、うまくNI-VISAが読み込めているようです。


Backends:
   ni:
      Version: 1.9.1 (bundled with PyVISA)
      #1: C:\WINDOWS\system32\visa32.dll:
         found by: auto
         bitness: 64
         Vendor: National Instruments
         Impl. Version: 19922944
         Spec. Version: 5244928
      #2: C:\WINDOWS\system32\visa64.dll:
         found by: auto
         bitness: 64
         Vendor: National Instruments
         Impl. Version: 19922944
         Spec. Version: 5244928

NI-VISAダウンロード後は、「pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.」が出なくなりました。

参考URL

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?