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 -0500

nishthapa gravatar image

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

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 imagemgruhler ( 2016-03-17 01:18:23 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

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

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 -0500

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 imagenishthapa ( 2016-03-18 02:12:34 -0500 )edit

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

mgruhler gravatar imagemgruhler ( 2016-03-18 12:24:32 -0500 )edit

Yes, I did that.

nishthapa gravatar imagenishthapa ( 2016-03-21 01:44:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 45 times

Last updated: Mar 21 '16