- 用
rosrun
python代码报错1:
(ros27) will@will-OptiPlex-9010:~/catkin_ws/src/test_ur$ rosrun test_ur moveit_ik_demo.py
[rosrun] Couldn't find executable named moveit_ik_demo.py below /home/will/catkin_ws/src/test_ur
[rosrun] Found the following, but they're either not files,
[rosrun] or not executable:
[rosrun] /home/will/catkin_ws/src/test_ur/moveit_ik_demo.py
解决方法:
要将python修改为可执行文件,就是添加授权
在terminal输入chmod 777 moveit_ik_demo.py
即可,对应的python文件名,注意修改。
- 报错2
(ros27) will@will-OptiPlex-9010:~/catkin_ws/src/test_ur$ rosrun test_ur moveit_ik_demo.py
import-im6.q16: not authorized `sys' @ error/constitute.c/WriteImage/1037.
import-im6.q16: not authorized `moveit_commander' @ error/constitute.c/WriteImage/1037.
from: can't read /var/mail/geometry_msgs.msg
/home/will/catkin_ws/src/test_ur/moveit_ik_demo.py: line 6: class: command not found
/home/will/catkin_ws/src/test_ur/moveit_ik_demo.py: line 7: syntax error near unexpected token `('
/home/will/catkin_ws/src/test_ur/moveit_ik_demo.py: line 7: ` def __init__(self):'
解决方法:
在python文件开头加入即可
#!/usr/bin/env python
# -*- coding: utf-8 -*-