pyvisa / pyvisa

A Python package with bindings to the "Virtual Instrument Software Architecture" VISA library, in order to control measurement devices and test equipment via GPIB, RS232, or USB.
https://pyvisa.readthedocs.io
MIT License
809 stars 250 forks source link

Error Library cant be found #765

Open charinano opened 1 year ago

charinano commented 1 year ago

hi, Last week I was using communicating just fine with my electronic load, but since yesterday, this error keeps coming up:

Traceback (most recent call last): File "C:\Python311\Lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 162, in _init lib = Library(self.library_path) File "C:\Python311\Lib\ctypes__init.py", line 376, in init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'C:\Program Files (x86)\IVI Foundation\VISA' (or one of its dependencies). Try using the full path with constructor syntax.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "<pyshell#11>", line 1, in rm=pyvisa.ResourceManager() File "C:\Python311\Lib\site-packages\pyvisa\highlevel.py", line 2992, in new visa_library = open_visa_library(visa_library) File "C:\Python311\Lib\site-packages\pyvisa\highlevel.py", line 2904, in open_visa_library return cls(argument) File "C:\Python311\Lib\site-packages\pyvisa\highlevel.py", line 191, in new obj._init() File "C:\Python311\Lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 164, in _init raise errors.LibraryError.from_exception(exc, self.library_path) pyvisa.errors.LibraryError: Error while accessing C:\Program Files (x86)\IVI Foundation\VISA: Could not find module 'C:\Program Files (x86)\IVI Foundation\VISA' (or one of its dependencies). Try using the full path with constructor syntax.

The only previous code lines were:

import pyvisa 
rm=pyvisa.ResourceManager()

I have tried adding the path directory in different ways: rm=pyvisa.ResourceManager('C:\Python311\Lib\site-packages\pyvisa') rm=pyvisa.ResourceManager('C:\Program Files (x86)\IVI Foundation\VISA') rm=pyvisa.ResourceManager('C:\WINDOWS\system32\visa32.dll') etc. I have deinstalled and re-installed everything related in my compiter from the Ni_Visa library to the pyvisa packages to python itself, deleted all the fast and tried again but the error keeps coming up.

When I write:

import pyvisa
rm=pyvisa.ResourceManager('@py')
print(rm.list_resources())

It returns an empty value (). And I dont know what else to try.

I'd greatly appreciate any prod in the right direction! Cheers

Instrument details

Output of pyvisa-info

C:\Users\chari>pyvisa-info Machine Details:

Processor: Intel64 Family 6 Model 126 Stepping 5, GenuineIntel

Python: Implementation: CPython Executable: C:\Python311\python.exe Version: 3.11.4 Compiler: MSC v.1934 64 bit (AMD64) Bits: 64bit Build: Jun 7 2023 05:45:37 (#tags/v3.11.4:d2340ef) Unicode: UCS4

PyVISA Version: 1.13.0

Backends: ivi: Version: 1.13.0 (bundled with PyVISA)

1: C:\WINDOWS\system32\visa32.dll:

     found by: auto
     bitness: 64
     Vendor: National Instruments
     Impl. Version: 24118528
     Spec. Version: 7340032
  #2: C:\WINDOWS\system32\visa64.dll:
     found by: auto
     bitness: 64
     Vendor: National Instruments
     Impl. Version: 24118528
     Spec. Version: 7340032

py: Version: 0.7.0 TCPIP INSTR: Available Resource discovery:

MatthieuDartiailh commented 1 year ago

One thing you can try is to use os.add_dll_directory in case there is some sort of permission issue.

After, because somebody reported a weird behavior on 3.11.4, could you try to downgrade to Python 3.11.3 and see if things work ?