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

error in import

asked 2014-10-15 06:02:59 -0500

Rahndall gravatar image

Dear ROS-Users

I created a service in my_package but I am not able to import it. In particular, using "from my_package import srv" in a ros-python node raise me this error: ImportError: cannot import name srv

However, doing the same "from my_package import srv" from a python shell, I don't get any error

I'm using catkin on ros-hydro and both catkin_make and catkin_make install don't give me any erro

Thank you for your help

edit retag flag offensive close merge delete


Could it be related to the PYTHONPATH?

Rahndall gravatar image Rahndall  ( 2014-10-15 07:29:42 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-10-29 04:54:14 -0500

Rahndall gravatar image

The problem was on the name of file: it gave me problem when package, file and node had the same name Sorry for the "noob" question

edit flag offensive delete link more

answered 2014-10-15 12:19:51 -0500

William gravatar image

I would check the spelling in your python ROS node. If you can import it in a python shell and get the error by running the python node in the same terminal then I would guess it is a typo.

We would need more information in order to guess why this is happening, things like the python script (or part of it), the exact process you use when setting up your environment, your environment when before running the script, etc...

It could be related to your PYTHONPATH, you can print it with print(sys.path) right before you try the import in your python node and make sure the folder which contains the service code is in the path.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-10-15 06:02:59 -0500

Seen: 1,280 times

Last updated: Oct 29 '14