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

I've suffered from unacceptable IMPORT error

asked 2019-12-04 08:17:35 -0500

kane_choigo gravatar image

Hello, I'm working with ROS kinetic on Ubuntu 16.04.

I'm trying tutorial of face_detector, but I faced a strange IMPORT error.

But I have the right module.

import rospy
from people_msgs.msg import PositionMeasurementArray

class FaceDetectClient(object):

def __init__(self):
    self.face_detect_subs = rospy.Subscriber("/face_detector/people_tracker_measurements_array", 
                                                PositionMeasurementArray, self.face_detect_subs_callback)
    self.pos_measurement_array = PositionMeasurementArray()

And the error message I've only got is

  File "/home/robotics/catkin_ws/src/my_face_detector/scripts/face_detector_client.py", line 4, in <module>
from people_msgs.msg import PositionMeasurementArray
 ImportError: No module named msg

 [ INFO] [1575467542.196464019]: You must subscribe to one of FaceDetector's outbound topics or else it will not publish anything.
[face_detection_client_start_node-2] process has died [pid 26265, exit code 1, cmd /home/robotics/catkin_ws/src/my_face_detector/scripts/face_detector_client.py __name:=face_detection_client_start_node __log:=/home/robotics/.ros/log/3f210cbc-169d-11ea-b72c-07b764ec1d1d/face_detection_client_start_node-2.log].
log file: /home/robotics/.ros/log/3f210cbc-169d-11ea-b72c-07b764ec1d1d/face_detection_client_start_node-2*.log

Because when I run some other packages in /opt/ros/kinetic/share/ directory (and also people_msgs package is in /opt/ros/kinetic/share/, it ran with any problem, I think it is not related to ros path.

If you happen to give me any advice, would you please let me know?

Thanks in advance :)

edit retag flag offensive close merge delete

Comments

Do you using some alternative python install like anaconda? This usually lead to some quite strange errors, as the ROS packages don't typically end up in the respective python paths those alternative installs use.

You can try to set the shebang of the script explicitely to /usr/bin/python2.7 (or wherever your python2.7 executable is located) and check if it works then (keep the ROS env sourced, though!)

mgruhler gravatar image mgruhler  ( 2019-12-05 01:34:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-12-04 16:20:21 -0500

I tested your code and it works for me (at least the import part).

I put some suggestions below:

source your ros setup

source /opt/ros/kinetic/setup.bash

check that people_msgs pkg is recognized by your setup:

rospack list | grep people_msgs

should give as result:

people_msgs /opt/ros/kinetic/share/people_msgs

if not, then install it:

sudo apt install ros-kinetic-people-msgs

This should solve your issue. Again, it works on my machine.

edit flag offensive delete link more

Comments

Thanks for your quick reply. I tried it following your comment, and although I got the message;people_msgs /opt/ros/kinetic/share/people_msgs, it still returns import error and really depresses me more and more. How did you do? I did just sudo apt-get install ros-kinetic-people-msgs and sudo apt-get install tos-kinetic-face-detector and the ImportError never go away.

kane_choigo gravatar image kane_choigo  ( 2019-12-04 21:32:54 -0500 )edit

Question Tools

Stats

Asked: 2019-12-04 08:17:35 -0500

Seen: 352 times

Last updated: Dec 04 '19