Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Python (PyVISA) "no module named 'visa' "

Hi,

 

I am planning on controlling a datalogger, oscilloscope and a power supply with a software written in Python. However, I have no previous experience with this field, and learning as I go. So far I have installed Python 3.6.5, PyVISA 1.9.0 and NI-VISA 18.0, as well as the IDE PyCharm.

 

I have an experienced programmer to help me with the code, but I am struggling to set up Python properly, as the following code ran in PyCharm gives me the error in the bottom of the dialog box:

 

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

Traceback (most recent call last):
File "C:/Users/bn/PycharmProjects/asdf/asdf.py", line 1, in <module>
import visa
ModuleNotFoundError: No module named 'visa'

 

I have tried googling the issue, and reinstalling as well as trying to create a "visa.pth" file that simply said "C:\Users\bn\AppData\Local\Programs\Python\Python36\Lib\site-packages" (the location of visa.py) to help guide the way to the VISA resource manager file, although I am not sure I am doing this right as I am not familiar at all with the basics of what a resource manager and a library is in this context. I am using pip as my package manager.

 

Any tips on what I am doing wrong, or things I have not tried? Alternatively any incompatibility I am missing, or installations I need. Any help is appreciated.

 

 

Python and PC specs:

 

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32

Operating System: Windows 10 Enterprise 64-bit (10.0, Build 17134) (17134.rs4_release.180410-1804)
System Manufacturer: Dell Inc.
System Model: Precision M2400
BIOS: Phoenix ROM BIOS PLUS Version 1.10 A28 (type: BIOS)
Processor: Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz (2 CPUs), ~2.4GHz
Page File: 2321MB used, 7074MB available
Windows Dir: C:\windows
DirectX Version: DirectX 12
DX Setup Parameters: Not found
User DPI Setting: 96 DPI (100 percent)
System DPI Setting: 96 DPI (100 percent)
DWM DPI Scaling: Disabled
Miracast: Not Available
Microsoft Graphics Hybrid: Not Supported
DxDiag Version: 10.00.17134.0001 64bit Unicode

 

0 Kudos
Message 1 of 3
(30,151 Views)

Solved. IDE was running duplicate Python executable as interpreter, with no PyVISA installed on it.

0 Kudos
Message 2 of 3
(30,120 Views)

Try conda:

https://www.anaconda.com/distribution/

 

Then in conda Prompt, get the PyVISA install....

$ pip install -U pyvisa-py

This worked for me

JR from Cape Town 

0 Kudos
Message 3 of 3
(27,035 Views)