Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
5.0k views
in Technique[技术] by (71.8m points)

python - pyvisa, function viOpen not found

When I run in 32 bit python,

import pyvisa
rm = pyvisa.ResourceManager()

I get this error:

Traceback (most recent call last): File "", line 1, in File "C:UserslatshawAppDataLocalProgramsPythonPython38-32libsite-packagespyvisahighlevel.py", line 3015, in new visa_library = open_visa_library(visa_library) File "C:UserslatshawAppDataLocalProgramsPythonPython38-32libsite-packagespyvisahighlevel.py", line 2929, in open_visa_library return cls(argument) File "C:UserslatshawAppDataLocalProgramsPythonPython38-32libsite-packagespyvisahighlevel.py", line 175, in new raise OSError("Could not open VISA library: " + " ".join(errs)) OSError: Could not open VISA library: function 'viOpen' not found

Here is what I have tried so far: re-installed with pip

$ pip install -U pyvisa

Here is some info of the install:

python -m visa info

C:UserslatshawAppDataLocalProgramsPythonPython38-32libsite-packagesvisa.py:13: FutureWarning: The visa module provided by PyVISA is being deprecated. You can replace import visa by import pyvisa as visa to achieve the same effect. The reason for the deprecation is the possible conflict with the visa package provided by the https://github.com/visa-sdk/visa-python which can result in hard to debug situations. warnings.warn

Machine Details: Platform ID: Windows-10-10.0.18362-SP0 Processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel

Python: Implementation: CPython Executable: C:UserslatshawAppDataLocalProgramsPythonPython38-32python.exe Version: 3.8.5 Compiler: MSC v.1926 32 bit (Intel) Bits: 32bit Build: Jul 20 2020 15:43:08 (#tags/v3.8.5:580fbb0) Unicode: UCS4

PyVISA Version: 1.11.3

Backends: ivi: Version: 1.11.3 (bundled with PyVISA) #1: C:windowssystem32visa32.dll: found by: auto bitness: 32 Could not get more info: function 'viOpen' not found

I am not sure what is going wrong here. From my research, it seems that the biggest 2 ways that people make mistakes are in mismatching a 32 version of pyvisa and a 64 bit version of IDLE (both of mine are 32 bit) and the other is in naming the file visa.py (which I am not doing).

Any help is greatly appreciated, cheers!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After some more digging, I found that this is a problem for python 3.8 as it does not load the DLL files correctly (something about an environmental PATH). In my specific case, I am interested in loading the keysight visa, so the below works for me.

import os
os.add_dll_directory('C:\Program Files (x86)\Keysight\IO Libraries Suite\bin')
import pyvisa
rm = pyvisa.ResourceManager('ktvisa32')

and now rm returns:

rm <enter>
<ResourceManager(<IVIVisaLibrary('ktvisa32')>)>

I think that this is the fix to my problem. However, I am running 'offline' right now and am not able to access the key-sight test equipment to see if I can talk to them over the python scripts. My fingers are crossed :)

Thanks for reading :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...