Should Py-Visa be usable as is on a BBB? I'll be attempting to install it tonight.
Should Py-Visa be usable as is on a BBB? I'll be attempting to install it tonight.
When I try to load the following into cloud9, I get the following error. How do I get the dang module to load?
# Import libraries
import visa
import os
import time
# Open a VISA resource manager pointing to the installation folder for the Keysight Visa libraries.
rm = visa.ResourceManager()
# ALTER LINE BELOW - Update the VISA resource string to match your specific VNA
myFF = rm.open_resource("TCPIP0::192.168.7.20::inst0::INSTR")
myFF.write(':FORMat:DATA %s,%d' % ('ASCii', 0))
Traceback (most recent call last):
File "/var/lib/cloud9/PILOT_Test/FFtransfer.py", line 8, in <module>
import visa
ImportError: No module named visaThis implies your Python installation doesn't have pyvisa installed because it fails in import visa.Try installing it again?
- Gough
Trying to log in from either the serial connection or the terminal on the BBB desktop, It errors saying pip is not valid/installed
Then its likely you have a very outdated version of Python. Try updating all the packages on your OS. If not, perhaps you can install pip - https://www.makeuseof.com/tag/install-pip-for-python/
Then its likely you have a very outdated version of Python. Try updating all the packages on your OS. If not, perhaps you can install pip - https://www.makeuseof.com/tag/install-pip-for-python/
I am typing these commands directly into my BBB... I am using the latest BBB image to boot from
The latest image doesn't necessarily mean it has the latest packages installed. Likewise, I don't use BBB at present, but its easier to update packages and install pip as I mentioned above. I don't know but I suspect BBB uses pacman instead of apt.
- Gough
The BBB does use apt, not pacman. JonA says he's using "latest" images, so it will be debian, which uses apt. Gough's link to make-use-of has clear instructions for installation and updating, just in case pip is an old version.
I just did a:
$ sudo apt-get install python3-pip
on my debian (ubuntu) laptop, and the version command returns this:
t440-ubuntu:~$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
JonA, did you check/confirm whether you're using python 2 (2.7), or python 3.x? After the above, I installed python-pip (pip2) and get the following:
t440-ubuntu:~$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
It looks like you don't have python-pip installed but you do have python3-pip installed. If you're intending to use Python 3, then you can use that.
I didn't realize BBB is Debian based, this makes it veryvsimilarsto the RPi.
I'd suggest you do something like:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
Then run the pip commands as listed before to install pyvisa.
- Gough
You may not care, but the computer might! There are subtle differences in the syntax between Python 2.x and 3.x which means they are not always interchangeable. The most glaring example is print - in 2.x, you could write print 'Hello', whereas 3.x requires print('Hello').
If your code is not impacted by the changes, you could try installing pyvisa on Python 3.x with pip3 rather than pip and run python3 scriptname.py rather than python scriptname.py
Regardless, did you run the commands in the last post that I suggested? That should upgrade all packages and install pip for Python 2.x so you can then run the commands to install pyvisa for Python 2.x as well.
- Gough
I understand what you are saying, but the root of your issue is that your BBB environment doesn't match that of your development PC.
By way of analogy, imagine if you wrote a text in English (your Python program that depends on pyvisa) and gave it to a friend next door (a Python interpreter on your PC) to read. As they can understand English (the pyvisa package is installed), this is no problem. Send the same text to a friend (another Python interpreter on your BBB) who is a native Chinese in China (does not have the pyvisa package installed yet) and they won't understand (program won't run as dependency is not met). They need to learn English (install the pyvisa package on the BBB), but in order to do that, they need to go to school (consult a package manager - pip). But their rural town has no school, so they must build one first (install pip from the OS package repository on the BBB).
Your BBB doesn't have pip installed so you can install pyvisa on the BBB. You can't just migrate your python script between environments and expect them to work unless all dependent modules are installed.
So as I said before and I will reiterate - update your packages on the BBB, install python2-pip package to get pip functionality, then use pip to install pyvisa on the BBB. If you get errors doing this, post them as that is the easiest way to help diagnose your issue.
- Gough