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

Importing python packages into node files

asked 2014-04-11 02:58:39 -0500

kamek gravatar image

I have set up my ROS package with the following layout:

packagename
  CMakeLists.txt
  package.xml
  |- src/
    |- packagename/
      |- __init__.py
      |- package_file.py
  |- scripts/
    |- node_file.py

And in node_file.py, I'd like to be able to do

from packagename import package_file

But I get cannot import name package file.

Am I laying this out correctly? How do I make my python package visible to node_file.py? I am using ROS Hydro in Ubuntu 12.04 LTS.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-04-11 03:39:06 -0500

kamek gravatar image

I didn't realize that I needed a setup.py file at the root of my package (I previously thought this was only needed for installing packages). I was used to using Fuerte where this was unnecessary. See here for how to create and use this file:

http://wiki.ros.org/rospy_tutorials/T...

edit flag offensive delete link more

Comments

Setup.py is very important, and should probably be added to the python publish/subscribe tutorials.

jackcviers gravatar image jackcviers  ( 2014-07-18 20:41:32 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-11 02:58:39 -0500

Seen: 261 times

Last updated: Apr 11 '14