I'm writing scripts to control test equipment. I've been using the visa library to create handles for the equipment. Everything has been working fine for a while until recently when I try to open my first resource in my code, it takes about 5 minutes before it finishes. Once the first equipment is open, the rest are fine.
The code goes something like:
import visa
rm = visa.ResourceManager()
equip1 = rm.open_resource(equip1_address)
equip2 = rm.open_resource(equip2_address)
I stepped through the code and found that it locks up in a functions.py file, in the open_default_resource_manager(library) function, at this line:
ret = library.viOpenDefaultRM(byref(session))
Here's my "python -m visa info":
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
Python:
Implementation: CPython
Executable: C:\python27\python.exe
Version: 2.7.17
Compiler: MSC v.1500 64 bit (AMD64)
Bits: 64bit
Build: Oct 19 2019 21:01:17 (#v2.7.17:c2f86d86e6)
Unicode: UCS2
PyVISA Version: 1.10.1
Backends:
ni:
Version: 1.10.1 (bundled with PyVISA)
#1: C:\Windows\system32\visa32.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 14680064
Spec. Version: 5243904
#2: C:\Windows\system32\visa64.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 14680064
Spec. Version: 5243904
For those familiar with Keysight Connection Expert, this is probably related. When I try to open it, it takes forever to load as well. Probably also having trouble locating the equipment?
Related
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:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 3015, in new
visa_library = open_visa_library(visa_library)
File "C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 2929, in open_visa_library
return cls(argument)
File "C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 175, in new
raise OSError("Could not open VISA library:\n" + "\n".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:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\visa.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:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\python.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:\windows\system32\visa32.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!
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 :)
I'm using
Mac OSX High Sierra
anaconda3 python (virtual environment with python=3.6)
Matlab R2018a.
Steps to reproduce:
Create a new python 3.6 environment. Activate the environment
Go to Matlab/extern/engines/python and run python setup.py install.
Run the following script.
import matlab.engine
matlab.engine.start_matlab()
Segmentation fault happen at the start_matlab() line (not the import line).
I had no trouble before using matlab engine this way. How could I debug this? (mostly is just linking problem).
======================
I uninstalled Anaconda3, and used Python 2.7 system. I met with the same problem, and the problem is with libwmvm.dylib of Matlab.
Process: Python [5124]
Path: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.10 (2.7.10)
Code Type: X86-64 (Native)
Parent Process: bash [2183]
Responsible: Python [5124]
User ID: 501
PlugIn Path: /Applications/MATLAB_R2018a.app/bin/maci64/libmwmvm.dylib
PlugIn Identifier: libmwmvm.dylib
PlugIn Version: ??? (0)
Date/Time: 2018-04-27 23:27:03.250 +0700
OS Version: Mac OS X 10.13.4 (17E199)
Report Version: 12
Anonymous UUID: 885790DC-B32C-0363-903C-837A7C285AF3
Sleep/Wake UUID: 14FBD560-D2B9-4A59-89F1-DABA878FCA70
Time Awake Since Boot: 10000 seconds
Time Since Wake: 3700 seconds
System Integrity Protection: enabled
Crashed Thread: 3
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000090
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
VM Regions Near 0x90:
-->
__TEXT 000000010e1c6000-000000010e1c8000 [ 8K] r-x/rwx SM=COW p [/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python]
Thread 0:: Dispatch queue: com.apple.main-thread
Matlab engine is not supported by python 3.6, you can use python 3.5.
I have anaconda, python 2.7, 3.5 and 3.6 also.
You can easily differentiate between them by renaming the python.exe to python35.exe for instance. Than you can call you py srcipt like this:
python35 example.py
And it will call it with python35.
Hint:
pip install and conda install won't work after the renaming, since it's searching for python.exe, so you don't have to rename the anaconda and the python version what you are using in most of the case.
I am embedding python with boost::python. Everything works fine until I set PYTHONPATH environment variable - then debugger crashes with message
The CDB process terminated
Debugger output
ERROR: Process crashed dCDB PROCESS FINISHED, status 1, exit code
-1073740791 dNOTE: ENGINE ILL ****** dState changed from EngineSetupRequested(1) to EngineShutdownRequested(19) [master] dCALL:
SHUTDOWN ENGINE dNOTE: ENGINE SHUTDOWN OK dState changed from
EngineShutdownRequested(19) to EngineShutdownOk(21) [master] dState
changed from EngineShutdownOk(21) to DebuggerFinished(22) [master]
sDebugger finished.
Qt Creator
Qt Creator 4.5.1 Based on Qt 5.10.1 (MSVC 2015, 32 bit)
Built on Feb 10 2018 04:20:12
From revision 24cd0b1cd6
Qt
5.10.0
Python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500
64 bit (AMD64)] on win32
VC
Microsoft (R) C/C++ Optimizing Compiler Version 19.12.25835 for x64
PYTHONHOME variable is set and not causing any issues at all.
WORKAROUND: Switched from Qt Creator 4.5.1 to 4.2.2
Qt Creator 4.2.2 Based on Qt 5.8.0 (MSVC 2015, 32 bit)
Built on Apr 3 2017 04:13:59
From revision 991f5eb6a5
https://forum.qt.io/topic/69130/unexpected-cdb-exit/12
#Christoph Schaefer
I have an error while connecting my device using GPIB interface by PYvisa.Below is the simple code i run.
>>> import visa;
>>> rm = visa.ResourceManager('C:/Windows/System32/visa32.dll');
>>> rm.list_resources();
('ASRL10::INSTR', 'ASRL71::INSTR')
But i don't see them getting detected as GPIB interface themselves.(like GPIB::25::INSTR).I have installed proper version of python and PyVISA. Below is the output for the same.
C:\>python -c "from pyvisa import util; util.get_debug_info()"
Machine Details:
Platform ID: Windows-7-6.1.7600
Processor: x86 Family 6 Model 58 Stepping 9, GenuineIntel
Python:
Implementation: CPython
Executable: C:\Python34\python.exe
Version: 3.4.3
Compiler: MSC v.1600 32 bit (Intel)
Bits: 32bit
Build: Feb 24 2015 22:43:06 (#v3.4.3:9b73f1c3e601)
Unicode: UCS4
PyVISA Version: 1.8
Backends:
ni:
Version: 1.8 (bundled with PyVISA)
#1: C:\Windows\system32\visa32.dll:
found by: auto
bitness: 32
Vendor: National Instruments
Impl. Version: 14680064
Spec. Version: 5243904
#2: C:\Windows\system32\visa32.dll:
found by: auto
bitness: 32
Vendor: National Instruments
Impl. Version: 14680064
Spec. Version: 5243904
Googling, i found that version and library path may be the possible reasons. But i guess that is not the issue in my case. Can anyone point out where am i going wrong as i am very much new to Python and pyVISA.
Check if your GPIB devices connected/detected via the NIMax panel. If it does not show up on the NIMax then your devices are not connected.
Additionally you should not need to put the visa32.dll path in visa.ResourceManager().
Objective:
Trying to run SL4A facade APIs from python shell on the host system (windows 7 PC)
My environment:
1. On my windows 7 PC, i have python 2.6.2
2. Android sdk tools rev 21, platform tools rev 16
3. API level 17 supported for JB 4.2
4. I have 2 devices ( one running android 2.3.3 and another android 4.2.2) both running Python for android and SL4A
I'm trying these commands as specified at http://code.google.com/p/android-scripting/wiki/RemoteControl
Here are the commands which i'm trying on the python shell:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> droid=android.Android
>>> droid.makeToast("Hello")
Traceback (most recent call last):
File "", line 1, in
AttributeError: type object 'Android' has no attribute 'makeToast'
Before this i'm performing the port forwarding and starting a private server as shown below
$ adb forward tcp:9999 tcp:4321
$ set AP_PORT=9999
Also set the server on the target listening on port 9999 ( through SL4A->preferences->serverport.
Please help to understand where i'm doing mistake which gives the above error while trying droid.makeToast("Hello") ?
Try
import android
droid=android.Android()
droid.makeToast("Hello")
(you are missing parentheses after android.Android)
Hope you solved the problem. This is what I found, so maybe for somebody else it will be useful.
You need to run all your commands inside the DOS shell...otherwise you will get that error[11001].
If you still want to run you commands outside the DOS shell - add a new environment variable as described here:
http://www.smartphonedaq.com/installation.page