How to define a python version for ROS
I try to run the teleop node using cmd:
rosrun turtlebot3_teleop turtlebot3_teleop_key
But I get an error
File "/home/goszjacek/catkin_ws/src/turtlebot3/turtlebot3_teleop/nodes/turtlebot3_teleop_key", line 140
print msg
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(msg)?
Python path is set to:
/home/goszjacek/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages
But anyway ROS tries to run the turtlebot3_teleop_key with python3. How can I force ROS to use 2.7, or can I change it in the settings?
Always add your ROS Distro to your question to get more directed answer. Because ROS Kinetic supports only python 2.7 but there are ways to compile it with different version.
If you run
python --version
which version is it using? Also check the shebang line at the beginning of the script (the line with#!/usr/bin/env python
)