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

Hi guys. I have built ROS from source on my PI 2 but I am unable to import libraries.

asked 2016-03-17 00:29:51 -0600

nishthapa gravatar image

updated 2016-03-18 01:38:07 -0600

I am not being able to import even the basic libraries such as with from std_msgs import Stringsin my python scripts. Please help me fix this issue.

EDIT

This is my CMakeLists.txt :

cmake_minimum_required(VERSION 2.8.3)
project(ior_internet)

find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)

catkin_package
(
 ##INCLUDE_DIRS include
 ##LIBRARIES ior_internet
 ##CATKIN_DEPENDS roscpp rospy std_msgs
 ##DEPENDS system_lib
)

And this is my package.xml :

<?xml version="1.0"?>
<package>
<name>ior_internet</name>
<version>0.0.0</version>
<description>The ior_internet package</description>

<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>

</package>
edit retag flag offensive close merge delete

Comments

This is not enough information

However, this could be a dependency issue, if you installed everything correctly. Please post your CMakeLists.txt as well as the package.xml (and also remove any comments, please).

mgruhler gravatar image mgruhler  ( 2016-03-17 01:18:23 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-03-21 01:47:11 -0600

nishthapa gravatar image

I figured it out. It was because I was not doing #!/usr/bin/env python at the beginning of my scripts. It seems it is important. Now my scripts work as expected.

edit flag offensive delete link more
1

answered 2016-03-18 01:45:07 -0600

mgruhler gravatar image

Duh, my bad. Could have seen this before.

The import statements for messages within rospy should look like this:

from std_msgs.msg import String
edit flag offensive delete link more

Comments

I tried that but i still get the same error. I cant import anything. Not even import rospy

nishthapa gravatar image nishthapa  ( 2016-03-18 02:12:34 -0600 )edit

Have you sourced /opt/ros/indigo/setup.bash? Or the respective workspace?

mgruhler gravatar image mgruhler  ( 2016-03-18 12:24:32 -0600 )edit

Yes, I did that.

nishthapa gravatar image nishthapa  ( 2016-03-21 01:44:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-17 00:29:51 -0600

Seen: 119 times

Last updated: Mar 21 '16