How to fix PyVISA "No module named 'serial.tools'"
Problem:
You want to use an ASRL (serial) instrument in PyVISA, but when you run
python3 -m visa info
you get this output even though you have serial
installed:
ASRL INSTR:
Please install PySerial (>=3.0) to use this resource type.
No module named 'serial.tools'
Solution
You have installed serial
but you need to install pyserial
- they are not the same!
First you need to remove the system package python3-serial
if installed. Example for Ubuntu/Debian:
sudo apt remove python3-serial
and also remove the pip serial
package if installed
sudo pip3 uninstall serial
Then install pyserial
:
sudo pip3 install pyserial
You can check if PySerial is installed properly using
python3 -m visa info
It should show you
ASRL INSTR: Available via PySerial (3.4)
once pyserial
is installed correctly!
***Note:***The commands above are for Python 3.x. In case you are still using Python 2.x use pip2
or pip
instead of pip3
and use python-serial
instead of python3-serial
as APT package name.