在ros中使用opencv启动例程 rosrun robot_vision cv_bridge_test.py 遇到的问题

本文档记录了在运行ROS(Robot Operating System)相关脚本cv_bridge_test.py时遇到的权限问题及Python语法错误。通过修改文件权限和修正print语句的语法,成功解决了问题。具体步骤包括使用chmod命令赋予文件执行权限,以及更新print语句以符合Python3的语法规范。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在运行这个例程的时候终端中出现:

[rosrun] Couldn't find executable named cv_bridge_test.py below /home/wyw/catkin_ws/src/robot_vision

[rosrun] Found the following, but they're either not files,

[rosrun] or not executable:

[rosrun]   /home/wyw/catkin_ws/src/robot_vision/scripts/cv_bridge_test.py

而当我们去找这个文件的时候却能够找到文件,其实是文件的访问权限出了问题,找到文件的所在目录,打开终端,输入命令:

chmod +x cv_bridge_test.py

问题解决

但是我在使用的时候终端报出几个错误:

第一:

File "/home/wyw/catkin_ws/src/robot_vision/scripts/cv_bridge_test.py", line 21

    print e

          ^

SyntaxError: Missing parentheses in call to 'print'. Did you mean print(e)?

这时我们将cv_bridge_test.py文件打开,将其中的print e 改成print (e)

注:()为英文的

第二

:<pre> File "/home/wyw/catkin_ws/src/robot_vision/scripts/cv_bridge_test.py", line 46

    print "Shutting down cv_bridge_test node."

          ^

SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Shutting down cv_bridge_test node.")?

</pre>

将cv_bridge_test.py文件打开,将其中的46行改为:    

 print ("Shutting down cv_bridge_test node.")

至此问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.百事从欢.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值