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().
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 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?
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.
Python version: 2.7.8
P4Python version: P4PYTHON/NTX86/2014.1/807760 (2014.1/807760 API) (2014/03/18)
Client OS: Win2k8 Server
Python script:
from P4 import P4, P4Exception
p4agent = P4()
p4agent.port = "ssl:my-perforce-server.com:1666"
p4agent.user = "abc"
p4agent.password = "a$3"
p4agent.connect()
p4agent.run_login()
Output:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 44, in <module>
getLatestRevision()
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 41, in getLatestRevision
initP4()
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 36, in initP4
p4agent.connect()
File "c:\python27\lib\site-packages\P4.py", line 678, in connect
P4API.P4Adapter.connect( self )
P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
SSL library must be at least version 1.0.1.
p4agent.identify() output:
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2014 Perforce Software. All rights reserved.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)
See 'p4 help legal' for full OpenSSL license information
Version of OpenSSL Libraries: OpenSSL 1.0.1d 5 Feb 2013
Rev. P4PYTHON/NTX86/2014.1/807760 (2014.1/807760 API) (2014/03/18).
The path to OpenSSL (lib) is set in the Path variable.
I also checked 'p4 set' on the client machine (from where I am trying to connect to the perforce server) and I see that all environment variables are properly set.
Can someone please let me know how to resolve this?
I believe the problem is that you are linking with the wrong Openssl library. The output of P4.identify() is misleading: this is the version of the OpenSSL the API was compiled with, not the version you are linking against.
Where did you get that version of P4Python from? Did you compile it yourself or did you download it from some other site?
If you want to use a ready-made version of P4Python for Windows Python 2.7 and 3.4 32bit and 64bit, please have a look at https://swarm.workshop.perforce.com/projects/p4pythonlib/files/p4pythonlib/bin. Let me know if you have any problems with these builds.
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