# Can't run simplePingExample.py

**URL:** <https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615>\
**Category:** Ping Sonar Devices\
**Created:** [June 23, 2020, 3:46pm UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615 "2020-06-23T15:46:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MohamedAli](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@MohamedAli](https://discuss.bluerobotics.com/u/MohamedAli)\
**Post date:** [June 23, 2020, 3:46pm UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615/1 "2020-06-23T15:46:19Z")

</div>

I am trying to run simplePingExample.py for " Ping Sonar Altimeter and Echosounder " on Linux PC but it doesn’t want to run and this error is appear:

Traceback (most recent call last):  
File “simplePingExample.py”, line 4, in   
from brping import Ping1D  
File “/home/ahmed/.local/lib/python2.7/site-packages/brping/ **init**.py”, line 4, in   
from brping.device import PingDevice  
File “/home/ahmed/.local/lib/python2.7/site-packages/brping/device.py”, line 38  
def connect\_serial(self, device\_name: str, baudrate: int =115200):  
^  
SyntaxError: invalid syntax

I followed this instruction from github : [GitHub - bluerobotics/ping-python: Python scripts and examples for the Ping sonar.](https://github.com/bluerobotics/ping-python)

the version of python and bluerobotics-ping library that I am using:  
Python 2.7.17  
bluerobotics-ping==0.1.0

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [June 23, 2020, 3:57pm UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615/2 "2020-06-23T15:57:22Z")

</div>

Hi @MohamedAli,

Python 2 is deprecated, please run or install it with Python 3.

> **[Python 2.7 Countdown](https://pythonclock.org/)**
>
> Python 2.7 will retire in 2020. Learn more and see the countdown here.

---

<div class="post-metadata">

**Author:** ![NULLCHA](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@NULLCHA](https://discuss.bluerobotics.com/u/NULLCHA)\
**Post date:** [July 12, 2020, 7:52am UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615/3 "2020-07-12T07:52:58Z")

</div>

Hi @patrickelectric,

I have same problem.

I am working simplePingExample.py in raspberry pi 3, I also followed the recommands in git hub.

And I used python3.4.

But I have same problem. The error message is follwoing.

ImportError: No module named ‘brping.definitinos’

I also add the path.

Please let me know how to solve it.

BR  
Sanghee Cha at Korea

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [July 20, 2020, 2:05pm UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615/4 "2020-07-20T14:05:01Z")

</div>

Hi Sanghee,

have you installed `bluerobotics-ping` with pip3 ?

---

<div class="post-metadata">

**Author:** ![i4mt](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@i4mt](https://discuss.bluerobotics.com/u/i4mt)\
**Post date:** [October 14, 2024, 11:23am UTC](https://discuss.bluerobotics.com/t/cant-run-simplepingexample-py/7615/5 "2024-10-14T11:23:19Z")

</div>

Hi,  
I am facing an issue with the simplePingExample.py.  
Opening /dev/ttyUSB0 at 115200 bps  
Traceback (most recent call last):  
File “/home/i4mt/ping-python/brping/device.py”, line 50, in connect\_serial  
self.iodev.send\_break()  
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 701, in send\_break  
termios.tcsendbreak(self.fd, int(duration / 0.25))  
termios.error: (32, ‘Broken pipe’)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/home/i4mt/ping-python/echo.py”, line 4, in   
myPing.connect\_serial(“/dev/ttyUSB0”, 115200)  
File “/home/i4mt/ping-python/brping/device.py”, line 55, in connect\_serial  
raise Exception(“Failed to open the given serial port: {0}”.format(exception))  
Exception: Failed to open the given serial port: (32, ‘Broken pipe’)

This is the error i get while running the code. I am running the code on raspberrypi 5 with raspbian os. The echosounder is working well because i have checked it using the ping-viewer. But on linux, it is not even opening the port. I enabled the Serial port permission on sudo raspi-config, added user permission for /dev/ttyUSB0, tried using raspberrypi 4, tried in a ubuntu system, tried using screen for monitoring the serial data but came out as a blank screen. Same problem persists.  
please help!
