我是 ROS 新手,
当我将 rospy 导入脚本文件 example.py 并运行它时遇到问题:它说:
Traceback (most recent call last):
File "/home/nagarjunv/hk_ws/src/rvo/src/example.py", line 4, in <module>
import rospy
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>
from .client import spin, myargv, init_node, \
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/client.py", line 52, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest # noqa: F401
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
我将以下内容导入到我的脚本文件中:第 4 行是 rospy
#!/usr/bin/env python3
import sys
import rospy
这是我的 CmakeLists:
cmake_minimum_required(VERSION 3.0.2)
project(rvo)
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
message_generation
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES rvo
CATKIN_DEPENDS rospy std_msgs
# DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
这是我的包 xml:
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>message_generation</build_export_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
我在 CMakelists 和 Package XML 'rospy' 中都指定并导入它。我还检查了我的 ros 是否有可用的 rospy 包。但是,我不明白为什么我无法运行我的脚本文件?
rosrun rvo example.py
我很乐意提供有关此错误的更多详细信息。任何人都可以让我知道这个问题的解决方案吗?