import rclpy error invalid syntax
when I try to run a simple python script to create a ROS2 node, I get an error immediately on the import rclpy
line at the top.
Running on Ubuntu 18.04 Bionic, ROS2 Dashing, deb package installed in /opt/ros/dashing/ directory shown below.
I have tried building from source as well and I get the same error (just to a different directory instead).
Probably missing some dependency or something. Any advice would be greatly appreciated!
NOTE: I can successfully run the ros2 demo_nodes_py talker and listener examples.....which use import rclpy in their code....
Traceback (most recent call last):
File "./bosch_imu_node.py", line 42, in <module>
import rclpy
File "/opt/ros/dashing/lib/python3.6/site-packages/rclpy/__init__.py", line 62
def init(*, args: List[str] = None, context: Context = None) -> None:
^
SyntaxError: invalid syntax
What's the command used to run your python script? Without a reproducible example my best guess is the script is being run using python 2, but ROS 2 code is all python 3.
that was it! all I had to do was update the bit bang to #!/usr/bin/env python3 and it solved that error