How to fix PyVISA not finding any ASRL (serial port) instruments

Problem:

You are trying to connect to a USB instrument using PyVISA & pyvisa-py, but the PyVISA resource manager doesn’t find any instruments:

example.py
#!/usr/bin/env python3
import visa
rm = visa.ResourceManager()
print(rm.list_resources()) # Prints "()" => No instruments found!

Solution

Install PySerial 3.0+:

First you need to remove the system package python3-serial if installed. Example for Ubuntu/Debian:

example.sh
sudo apt remove python3-serial

and also remove the pip serial package if installed (we need to install pyserial, not serial!)

example.sh
pip uninstall serial

Then install pyserial:

example.sh
pip install -U pyserial

You can check if PySerial is installed properly using

example.sh
python3 -m visa info

It should show you

example.txt
ASRL INSTR: Available via PySerial (3.4)

if pyserial is installed correctly!

***Note:***The commands above are for Python 3.x. In case you are still using Python 2.x use pip2 instead of pip and use python-serial instead of python3-serial as APT package name.


Check out similar posts by category: Electronics, Python