I am trying to obtain the echo sounder distance mesurement in python using a rasbery pi connected through ssh to windows 10 , I have followed the github installation guidance . I have also used pip3 to download the package but when I try to execute the program using the following command ( simplePingExample.py --device/dev/ttyUSB0 ) ( I have tried from ttyUSB0 to ttyUSB4)but I keep on getting the following error
Traceback (most recent call last):
File “/home/pi/.local/bin/simplePingExample.py”, line 4, in import(‘pkg_resources’).run_script(‘bluerobotics-ping==0.1.0’, ‘simplePingExample.py’)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 1437, in run_script
.format(**locals()),
pkg_resources.ResolutionError: Script ‘scripts/simplePingExample.py’ not found in metadata at '/home/pi/.l
Could you please guide me through What I am doing wrong ? , I have tried connecting to the echosounder using an arduino , and everything seemed to run smoothly , which is not the case in python
The end of your error traceback seems to be missing, so it’s not clear what’s actually going wrong.
I just tried this using the Raspberry Pi 3 companion computer in the ROV and it worked for me
ssh pi@raspberrypi.local
pi@raspberrypi.local's password:
# install bluerobotics-ping library and dependencies for python 3
pi@raspberrypi:~ $ sudo pip3 install bluerobotics-ping
# stop the companion 'pingproxy' service to allow script connection instead
pi@raspberrypi:~ $ screen -S pingproxy -X quit
# run the simple Ping example on the first Ping1D device detected by companion
pi@raspberrypi:~ $ simplePingExample.py --device $(ls -d /dev/serial/ping/Ping1* | head -1)
For just the commands I ran once ssh’d in:
# install bluerobotics-ping library and dependencies for python 3
sudo pip3 install bluerobotics-ping
# stop the companion 'pingproxy' service to allow script connection instead
screen -S pingproxy -X quit
# run the simple Ping example on the first Ping1D device detected by companion
simplePingExample.py --device $(ls -d /dev/serial/ping/Ping1* | head -1)
Note that if you’re not using our companion image you won’t need to quit the ‘pingproxy’ service, but you will need to manually specify the usb port, e.g.
# install bluerobotics-ping library and dependencies for python3
sudo pip3 install bluerobotics-ping
# run the simple Ping example on USB0 (may need to change device)
simplePingExample.py --device /dev/ttyUSB0
Thank you Eliot for the reply , but sadly when I tried to run the command that you have shared with me
simplePingExample.py --device $(ls -d /dev/serial/ping/Ping1 | head -1)
it seemed that there was no “/ping” folder under /serial ( you can check the screenshot )
And when I try to run directly the simplePingExample.py --device /dev/ttyUSB0 of course trying diffrent USB numbers 0-4 , I get the same error previously
simplePingExample.py --device /dev/ttyUSB0
Traceback (most recent call last):
File “/home/pi/.local/bin/simplePingExample.py”, line 4, in import(‘pkg_resources’).run_script(‘bluerobotics-ping==0.1.0’, ‘simplePingExample.py’)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 1437, in run_script
.format(**locals()),
pkg_resources.ResolutionError: Script ‘scripts/simplePingExample.py’ not found in metadata at ‘/home/pi/.local/lib/python3.7/site-packages/bluerobotics_ping-0.1.0.dist-info’
Could you please help me out, As I have mentioned previously, I am just trying to read the distance data using in python , using raspberry Pi 3
I’m assuming that’s the case here? /serial/ping/ is something our companion software sets up, so understandably it won’t exist if you’re not using that software.
If you want you can try to check which USB device it’s been assigned to by running dmesg | grep usb | grep FTDI, which searches the kernel startup messages for detection of a connected FTDI device (serial to USB converter).
I’m not sure why you’re getting that issue, and I can’t reproduce it on my Raspberry Pi 3B or my laptop. I’m a bit confused by the error message you’re getting, and also notice that in your screenshot you’re seemingly in a ~/ping-python/examples directory, which seems like you’ve cloned the code instead of installing it, or that you’ve installed AND cloned it, in which case it may be struggling to find the correct simplePingExample.py to use (when the library is installed it’s supposed to make that file available as a script from anywhere, but that may be conflicting with the one in the directory that you’re in.
I’d suggest you try the following:
# return to the home directory
cd ~
# install the latest version of bluerobotics-ping (0.1.1)
sudo pip3 install --upgrade bluerobotics-ping
# determine which USB to connect to (/dev/ttyUSBx)
dmesg | grep usb | grep FTDI
# run the ping example on that (TODO: set the correct device!)
simplePingExample.py --device /dev/ttyUSB_
If that works for you then you likely want to delete your ~/ping-python/ directory