Linux Setup
Complete guide to install and configure PyVISA on Linux with NI-VISA drivers, USB permissions, udev rules, and serial port setup.
Install PyVISA
Install the python3-pyvisa package using apt.
sudo apt update
sudo apt install -y python3-pyvisaNote: installing PyVISA using pip only inside a venv will not work. The package needs to be installed system-wide first.
Test your setup
In the terminal:
python3 -c "import pyvisa; print(pyvisa.ResourceManager('@py').list_resources())"You should see a list containing your device in the format INTERFACE::VID::PID::SN::INSTR.
Method Using the NI-VISA Backend
Install these if you still do not see your device, for most interfaces pyvisa-py is sufficient.
Step 1: Get the NI-VISA driver and backend
- Download the NI package: Visit the NI-VISA download page. Unfortunately, registration is needed. Extract the archive, you should see
.debpackages.
Step 2: Install NI-VISA for your distribution
-
Install NI-VISA: Example for Ubuntu: install the downloaded
.debpackage usingdpkg. There are two packages, a "stream" and fixed quarterly version. Use the fixed quarterly version for reproductibility.sudo dpkg -i ni-visa_20*.deb sudo apt update sudo apt install -y ni-visa
Step 3: Configure PyVISA to Use NI-VISA Backend
- Set NI-VISA Backend: Ensure that PyVISA uses the NI-VISA backend.
You can also provide a direct library path, for example:import pyvisa rm = pyvisa.ResourceManager('@ni')/usr/lib/x86_64-linux-gnu/libvisa.so. The path for pyvisa-py is@pi.
Step 4: Verify Device Connection
-
Use visaconf Utility: Use the
visaconfNI terminal utility to check your device's connection. -
In Python:
python3 -c "import pyvisa; print(pyvisa.ResourceManager('@py').list_resources())"Virtual Environment (venv)
The python3-pyvisa and python3-pyvisa-py packages must be installed system-wide. After a venv can be used. Installing them in a virtual environment only will not work.
Commands for installing in a venv:
pip install PyVISA PyVISA-pyNote: installing the python3-pyvisa package also installs python3-pyvisa-py in debian-based distributions by default.
PyVisa-py is a Python VISA backend that replaces the NI backend.
Notes
- Firewall Settings: For Ethernet devices, ensure your firewall settings allow communication with the instrument.
- Windows Fast Startup Interference: Windows Fast Startup can prevent interfaces to reset properly and interfere with device detection.
- Some devices expect termination characters at the end of the commands. Please refer to the dedicated section on the Interfaces page.
Windows Setup
How to install PyVISA on Windows with NI-VISA or Keysight IO Libraries drivers, virtual environments, and corporate proxy configuration.
PyVISA-py Backend
How to use PyVISA-py as a pure-Python VISA backend with no vendor drivers. Installation, supported interfaces, limitations, and when to use it.