无法打印法外狂徒张三18岁爱吃鱼香肉丝
-
标题:ros2 run demo_python_pkg human_node出错
Traceback (most recent call last):
File "/home/ros/chapt2_2/chapt2_2_ws/install/demo_python_pkg/lib/demo_python_pkg/human_node", line 33, in <module>
sys.exit(load_entry_point('demo-python-pkg==0.0.0', 'console_scripts', 'human_node')())
File "/home/ros/chapt2_2/chapt2_2_ws/install/demo_python_pkg/lib/demo_python_pkg/human_node", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.10/importlib/metadata/init.py", line 173, in load
return functools.reduce(getattr, attrs, module)
AttributeError: module 'demo_python_pkg.human_node' has no attribute 'main'
[ros2run]: Process exited with failure 1背景(可选):
打印法外狂徒张三18岁爱吃鱼香肉丝
问题描述:
colcon build 可以看到有可执行文件human_node
具体细节和上下文:
colcon build
source install/setup.bash
ros2 run demo_python_pkg human_node这一步失败了,好几次;setup.py的内容
human_node.py的内容
尝试过的解决方法:
直接把Traceback (most recent call last):
File "/home/ros/chapt2_2/chapt2_2_ws/install/demo_python_pkg/lib/demo_python_pkg/human_node", line 33, in <module>
sys.exit(load_entry_point('demo-python-pkg==0.0.0', 'console_scripts', 'human_node')())
File "/home/ros/chapt2_2/chapt2_2_ws/install/demo_python_pkg/lib/demo_python_pkg/human_node", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.10/importlib/metadata/init.py", line 173, in load
return functools.reduce(getattr, attrs, module)
AttributeError: module 'demo_python_pkg.human_node' has no attribute 'main'
[ros2run]: Process exited with failure 1
复制搜索答案,没看懂 -
@1635731080 看一眼目录结构正不正确
demo_python_pkg/
│ ├──__init__.py # 确保存在(可为空文件)
│ └── human_node.py # 包含 main() 函数 -
@1635731080 def main()前面多了空格