0
$\begingroup$

Rosanswers logo

I am converting the ros-trimble-bd960 package to read from a socket rather than serial port. I thought this was pretty straight forward as they read the same type of data but I just needed to change a few things in the code. I can upload what i have to a github repo if needed. I have tested the socket stream away from ROS and had no problems. I know this error is apparently something wrong with my python setup but would like some direction. Running both launch files gives the same error:

Traceback (most recent call last):
  File "/home/user/catkin_ws/src/ros-trimble-bd960/scripts/gps.py", line 3, in <module>
    import rospy
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 49, in <module>
    from .client import spin, myargv, init_node, \
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/client.py", line 60, in <module>
    import rospy.impl.init
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/init.py", line 54, in <module>
    from .tcpros import init_tcpros
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros.py", line 45, in <module>
    import rospy.impl.tcpros_service
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 54, in <module>
    from rospy.impl.tcpros_base import TCPROSTransport, TCPROSTransportProtocol, \
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 167
    (e_errno, msg, *_) = e.args
                   ^
SyntaxError: invalid syntax
[gps-2] process has died [pid 13458, exit code 1, cmd /home/chase/catkin_ws/src/ros-trimble-bd960/scripts/gps.py __name:=gps __log:=/home/user/.ros/log/4dde074c-766b-11ed-978b-f7fbe9041b00/gps-2.log].
log file: /home/chase/.ros/log/4dde074c-766b-11ed-978b-f7fbe9041b00/gps-2*.log

Originally posted by chased11 on ROS Answers with karma: 137 on 2022-12-07

Post score: 0


Original comments

Comment by ljaniec on 2022-12-11:
Which Ubuntu do you have? If 20.04, you can install python-is-python3 package to use Python 3.x as default one

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This is a python2 vs. python3 mismatch. My guess that you are invoking the python2 interpreter, which is not supported by noetic.

One small step to avoiding these kind of issues to make sure that /usr/bin/python is a symlink to python3, not python2.


Originally posted by Mike Scheutzow with karma: 4903 on 2022-12-07

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by chased11 on 2022-12-12:
Yep that was the problem/ Fix was starting the scripts with #! /usr/bin/python3. The package I installed was using python 2.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.