ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to define a python version for ROS

asked 2019-11-29 07:24:21 -0600

goszjacek gravatar image

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:


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?

edit retag flag offensive close merge delete


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.

Gokul gravatar image Gokul  ( 2019-11-30 16:29:21 -0600 )edit

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)

ejalaa12 gravatar image ejalaa12  ( 2021-02-25 15:42:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-30 16:33:07 -0600

Gokul gravatar image

You can use this command

catkin build --cmake-args -DPYTHON_VERSION=2.7

For further reference, you can try out different solution posted here for this question

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-11-29 07:24:21 -0600

Seen: 4,586 times

Last updated: Nov 30 '19